cid#1607171 Data race condition
[LibreOffice.git] / reportbuilder / java / org / libreoffice / report / pentaho / styles / StyleMappingDocumentReadHandler.java
bloba7ba49b04f514ebb4acad9e6de94a3069e8c04a0
1 /*
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;
30 /**
31 * Todo: Document me!
33 * @since 12.03.2007
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();
47 /**
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.
56 @Override
57 protected XmlReadHandler getHandlerForChild(final String uri,
58 final String tagName,
59 final Attributes atts)
60 throws SAXException
62 if (isSameNamespace(uri) && "mapping".equals(tagName))
64 final StyleMappingReadHandler smr = new StyleMappingReadHandler();
65 mappings.add(smr);
66 return smr;
68 return null;
71 /**
72 * Done parsing.
74 * @throws org.xml.sax.SAXException if there is a parsing error.
76 @Override
77 protected void doneParsing()
78 throws SAXException
80 for (int i = 0; i < mappings.size(); i++)
82 final StyleMappingReadHandler handler = mappings.get(i);
83 styleMapper.addMapping(handler.getRule());
87 /**
88 * Returns the object for this element or null, if this element does not
89 * create an object.
91 * @return the object.
93 public StyleMapper getObject()
94 throws SAXException
96 return styleMapper;