2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.io
.tcsxml
;
11 import org
.apache
.log4j
.Logger
;
12 import org
.jdom
.Content
;
13 import org
.jdom
.Element
;
14 import org
.jdom
.Namespace
;
16 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IXmlMapper
;
17 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.CdmSingleAttributeMapperBase
;
26 public abstract class CdmSingleAttributeXmlMapperBase
extends CdmSingleAttributeMapperBase
implements IXmlMapper
{
27 @SuppressWarnings("unused")
28 private static final Logger logger
= Logger
.getLogger(CdmSingleAttributeXmlMapperBase
.class);
30 protected Namespace sourceNamespace
;
34 * @param sourceElementString
35 * @param sourceNamespace
36 * @param cdmAttributeString
38 protected CdmSingleAttributeXmlMapperBase(String sourceElementString
,Namespace sourceNamespace
, String cdmAttributeString
){
39 super(sourceElementString
, cdmAttributeString
);
45 * Uses the Namespace of the parent Element
46 * @param sourceElementString
47 * @param cdmAttributeString
49 protected CdmSingleAttributeXmlMapperBase(String sourceElementString
, String cdmAttributeString
){
50 super(sourceElementString
, cdmAttributeString
);
54 public String
getSourceElement(){
55 return super.getSourceAttribute();
58 public String
getDestinationAttribute(){
59 return super.getDestinationAttribute();
63 public Namespace
getSourceNamespace(){
64 return sourceNamespace
;
68 * Returns the namespace. If namespace is null, return parentElement namespace
69 * @param parentElement
72 public Namespace
getSourceNamespace(Element parentElement
){
73 if (this.sourceNamespace
!= null){
74 return sourceNamespace
;
75 }else if (parentElement
!= null){
76 return parentElement
.getNamespace();
82 public boolean mapsSource(Content content
, Element parentElement
){
83 if (! (content
instanceof Element
)){
86 Element element
= (Element
)content
;
89 }else if (! element
.getName().equals(getSourceElement())){
92 Namespace thisNamespace
= getSourceNamespace(parentElement
);
93 if (thisNamespace
== null){
94 if (element
.getNamespace() == null){
100 if (! thisNamespace
.equals(element
.getNamespace())){
106 public String
toString(){
108 return this.getSourceElement();