1*1a37d047SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1a37d047SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1a37d047SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1a37d047SAndrew Rist * distributed with this work for additional information 6*1a37d047SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1a37d047SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1a37d047SAndrew Rist * "License"); you may not use this file except in compliance 9*1a37d047SAndrew Rist * with the License. You may obtain a copy of the License at 10*1a37d047SAndrew Rist * 11*1a37d047SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1a37d047SAndrew Rist * 13*1a37d047SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1a37d047SAndrew Rist * software distributed under the License is distributed on an 15*1a37d047SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1a37d047SAndrew Rist * KIND, either express or implied. See the License for the 17*1a37d047SAndrew Rist * specific language governing permissions and limitations 18*1a37d047SAndrew Rist * under the License. 19*1a37d047SAndrew Rist * 20*1a37d047SAndrew Rist *************************************************************/ 21*1a37d047SAndrew Rist 22*1a37d047SAndrew Rist 23cdf0e10cSrcweir package com.sun.star.report.pentaho.styles; 24cdf0e10cSrcweir 25cdf0e10cSrcweir /** 26cdf0e10cSrcweir * A hash key for the stylemapper. 27cdf0e10cSrcweir * 28cdf0e10cSrcweir * @author Thomas Morgner 29cdf0e10cSrcweir * @since 12.03.2007 30cdf0e10cSrcweir */ 31cdf0e10cSrcweir public final class StyleMapperKey 32cdf0e10cSrcweir { 33cdf0e10cSrcweir 34cdf0e10cSrcweir private final String elementNamespace; 35cdf0e10cSrcweir private final String elementName; 36cdf0e10cSrcweir private final String attributeNamespace; 37cdf0e10cSrcweir private final String attributeName; 38cdf0e10cSrcweir private final int hashCode; 39cdf0e10cSrcweir StyleMapperKey(final String elementNamespace, final String elementName, final String attributeNamespace, final String attributeName)40cdf0e10cSrcweir public StyleMapperKey(final String elementNamespace, 41cdf0e10cSrcweir final String elementName, 42cdf0e10cSrcweir final String attributeNamespace, 43cdf0e10cSrcweir final String attributeName) 44cdf0e10cSrcweir { 45cdf0e10cSrcweir if (elementNamespace == null) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir throw new NullPointerException(); 48cdf0e10cSrcweir } 49cdf0e10cSrcweir if (elementName == null) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir throw new NullPointerException(); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir this.elementNamespace = elementNamespace; 55cdf0e10cSrcweir this.elementName = elementName; 56cdf0e10cSrcweir this.attributeNamespace = attributeNamespace; 57cdf0e10cSrcweir this.attributeName = attributeName; 58cdf0e10cSrcweir this.hashCode = computeHashCode(); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir getElementNamespace()61cdf0e10cSrcweir public String getElementNamespace() 62cdf0e10cSrcweir { 63cdf0e10cSrcweir return elementNamespace; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir getElementName()66cdf0e10cSrcweir public String getElementName() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir return elementName; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir getAttributeNamespace()71cdf0e10cSrcweir public String getAttributeNamespace() 72cdf0e10cSrcweir { 73cdf0e10cSrcweir return attributeNamespace; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir getAttributeName()76cdf0e10cSrcweir public String getAttributeName() 77cdf0e10cSrcweir { 78cdf0e10cSrcweir return attributeName; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir equals(final Object o)81cdf0e10cSrcweir public boolean equals(final Object o) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir if (this != o) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir if (o == null || getClass() != o.getClass()) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir return false; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir final StyleMapperKey that = (StyleMapperKey) o; 91cdf0e10cSrcweir 92cdf0e10cSrcweir if ((attributeName != null ? !attributeName.equals(that.attributeName) : that.attributeName != null) || (attributeNamespace != null ? !attributeNamespace.equals(that.attributeNamespace) : that.attributeNamespace != null) || !elementName.equals(that.elementName) || !elementNamespace.equals(that.elementNamespace)) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir return false; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir return true; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir computeHashCode()101cdf0e10cSrcweir private int computeHashCode() 102cdf0e10cSrcweir { 103cdf0e10cSrcweir int result = elementNamespace.hashCode(); 104cdf0e10cSrcweir result = 31 * result + elementName.hashCode(); 105cdf0e10cSrcweir result = 31 * result + (attributeNamespace != null ? attributeNamespace.hashCode() : 0); 106cdf0e10cSrcweir result = 31 * result + (attributeName != null ? attributeName.hashCode() : 0); 107cdf0e10cSrcweir return result; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir hashCode()110cdf0e10cSrcweir public int hashCode() 111cdf0e10cSrcweir { 112cdf0e10cSrcweir return hashCode; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir } 115