cid#1607171 Data race condition
[LibreOffice.git] / reportbuilder / java / org / libreoffice / report / pentaho / styles / StyleMappingReadHandler.java
blob3360f61e1840c97c8ad663d49b15fead6db9750a
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 org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler;
21 import org.pentaho.reporting.libraries.xmlns.parser.ParseException;
23 import org.xml.sax.Attributes;
24 import org.xml.sax.SAXException;
26 /**
27 * Todo: Document me!
29 * @since 12.03.2007
31 public class StyleMappingReadHandler extends AbstractXmlReadHandler
34 private StyleMappingRule rule;
36 /**
37 * Starts parsing.
39 * @param attrs the attributes.
40 * @throws org.xml.sax.SAXException if there is a parsing error.
42 @Override
43 protected void startParsing(final Attributes attrs)
44 throws SAXException
46 final String elementNamespace = attrs.getValue(getUri(),
47 "element-namespace");
48 if (elementNamespace == null)
50 throw new ParseException("Required attribute 'element-namespace' is missing", getLocator());
53 final String elementName = attrs.getValue(getUri(), "element-name");
55 if (elementName == null)
57 throw new ParseException("Required attribute 'element-name' is missing", getLocator());
60 final String attributeNamespace = attrs.getValue(getUri(),
61 "attribute-namespace");
62 final String attributeName = attrs.getValue(getUri(), "attribute-name");
64 final boolean listOfValues =
65 "styleNameRefs".equals(attrs.getValue(getUri(), "type"));
67 final String family = attrs.getValue(getUri(), "style-family");
68 final StyleMapperKey key = new StyleMapperKey(elementNamespace, elementName, attributeNamespace, attributeName);
69 rule = new StyleMappingRule(key, family, listOfValues);
72 public StyleMappingRule getRule()
74 return rule;
77 /**
78 * Returns the object for this element or null, if this element does not
79 * create an object.
81 * @return the object.
83 public Object getObject()
84 throws SAXException
86 return rule;