001package com.hfg.xml.xsd; 002 003import com.hfg.xml.XMLNamespace; 004import com.hfg.xml.XMLNode; 005 006//------------------------------------------------------------------------------ 007/** 008 Base representation of a type element in an XML Schema Definition (XSD) specification. 009 <div> 010 @author J. Alex Taylor, hairyfatguy.com 011 </div> 012 */ 013//------------------------------------------------------------------------------ 014// com.hfg XML/HTML Coding Library 015// 016// This library is free software; you can redistribute it and/or 017// modify it under the terms of the GNU Lesser General Public 018// License as published by the Free Software Foundation; either 019// version 2.1 of the License, or (at your option) any later version. 020// 021// This library is distributed in the hope that it will be useful, 022// but WITHOUT ANY WARRANTY; without even the implied warranty of 023// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 024// Lesser General Public License for more details. 025// 026// You should have received a copy of the GNU Lesser General Public 027// License along with this library; if not, write to the Free Software 028// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 029// 030// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 031// jataylor@hairyfatguy.com 032//------------------------------------------------------------------------------ 033 034public abstract class XsdType 035{ 036 private String mName; 037 private String mAnnotation; 038 private XMLNamespace mNamespace; 039 040 //--------------------------------------------------------------------------- 041 public XsdType(String inName) 042 { 043 mName = inName; 044 } 045 046 //--------------------------------------------------------------------------- 047 public XsdType(XMLNode inTag) 048 { 049 mName = inTag.getAttributeValue(XsdXML.NAME_ATT.getLocalName()); 050 051 for (XMLNode subtag : inTag.getXMLNodeSubtags()) 052 { 053 if (subtag.getTagName().equals(XsdXML.ANNOTATION.getLocalName())) 054 { 055 setAnnotation(subtag.getRequiredSubtagByName(XsdXML.DOCUMENTATION.getLocalName()).getUnescapedContent()); 056 } 057 } 058 } 059 060 //--------------------------------------------------------------------------- 061 public String toString() 062 { 063 return getLocalName(); 064 } 065 066 //--------------------------------------------------------------------------- 067 public String getQualifiedName() 068 { 069 return (mNamespace != null && mNamespace.getPrefix() != null ? mNamespace.getPrefix() + ":" : "") + mName; 070 } 071 072 //--------------------------------------------------------------------------- 073 public String getLocalName() 074 { 075 return mName; 076 } 077 078 //--------------------------------------------------------------------------- 079 public XsdType setAnnotation(String inValue) 080 { 081 mAnnotation = inValue; 082 return this; 083 } 084 085 //--------------------------------------------------------------------------- 086 public String getAnnotation() 087 { 088 return mAnnotation; 089 } 090 091 //--------------------------------------------------------------------------- 092 public XsdType setNamespace(XMLNamespace inValue) 093 { 094 mNamespace = inValue; 095 return this; 096 } 097 098 //--------------------------------------------------------------------------- 099 public XMLNamespace getNamespace() 100 { 101 return mNamespace; 102 } 103}