2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package org
.libreoffice
.report
.pentaho
.styles
;
20 import java
.util
.ArrayList
;
21 import java
.util
.List
;
23 import org
.pentaho
.reporting
.libraries
.xmlns
.parser
.AbstractXmlReadHandler
;
24 import org
.pentaho
.reporting
.libraries
.xmlns
.parser
.XmlReadHandler
;
26 import org
.xml
.sax
.Attributes
;
27 import org
.xml
.sax
.SAXException
;
35 public class StyleMappingDocumentReadHandler
extends AbstractXmlReadHandler
38 private final StyleMapper styleMapper
;
39 private final List
<StyleMappingReadHandler
> mappings
;
41 public StyleMappingDocumentReadHandler()
43 this.mappings
= new ArrayList
<StyleMappingReadHandler
>();
44 this.styleMapper
= new StyleMapper();
48 * Returns the handler for a child element.
50 * @param tagName the tag name.
51 * @param atts the attributes.
52 * @return the handler or null, if the tagname is invalid.
54 * @throws org.xml.sax.SAXException if there is a parsing error.
57 protected XmlReadHandler
getHandlerForChild(final String uri
,
59 final Attributes atts
)
62 if (isSameNamespace(uri
) && "mapping".equals(tagName
))
64 final StyleMappingReadHandler smr
= new StyleMappingReadHandler();
74 * @throws org.xml.sax.SAXException if there is a parsing error.
77 protected void doneParsing()
80 for (int i
= 0; i
< mappings
.size(); i
++)
82 final StyleMappingReadHandler handler
= mappings
.get(i
);
83 styleMapper
.addMapping(handler
.getRule());
88 * Returns the object for this element or null, if this element does not
93 public StyleMapper
getObject()