001package com.hfg.svg; 002 003import com.hfg.util.collection.CollectionUtil; 004import com.hfg.xml.XMLAttribute; 005import com.hfg.xml.XMLTag; 006import com.hfg.xml.rdf.RDF; 007 008import java.util.List; 009 010//------------------------------------------------------------------------------ 011/** 012 * Object representation of an SVG (Scalable Vector Graphics) 'metadata' tag. 013 * <div> 014 * @author J. Alex Taylor, hairyfatguy.com 015 * </div> 016 */ 017//------------------------------------------------------------------------------ 018// com.hfg XML/HTML Coding Library 019// 020// This library is free software; you can redistribute it and/or 021// modify it under the terms of the GNU Lesser General Public 022// License as published by the Free Software Foundation; either 023// version 2.1 of the License, or (at your option) any later version. 024// 025// This library is distributed in the hope that it will be useful, 026// but WITHOUT ANY WARRANTY; without even the implied warranty of 027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 028// Lesser General Public License for more details. 029// 030// You should have received a copy of the GNU Lesser General Public 031// License along with this library; if not, write to the Free Software 032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 033// 034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 035// jataylor@hairyfatguy.com 036//------------------------------------------------------------------------------ 037 038public class SvgMetadata extends AbstractSvgNode implements SvgNode 039{ 040 041 //########################################################################## 042 // CONSTRUCTORS 043 //########################################################################## 044 045 //--------------------------------------------------------------------------- 046 public SvgMetadata() 047 { 048 super(SVG.metadata); 049 } 050 051 //--------------------------------------------------------------------------- 052 public SvgMetadata(XMLTag inXMLTag) 053 { 054 this(); 055 initFromXMLTag(inXMLTag); 056 } 057 058 //########################################################################## 059 // PUBLIC METHODS 060 //########################################################################## 061 062 //--------------------------------------------------------------------------- 063 public SvgMetadata setId(String inValue) 064 { 065 setAttribute(SvgAttr.id, inValue); 066 return this; 067 } 068 069 //########################################################################## 070 // PROTECTED METHODS 071 //########################################################################## 072 073 //--------------------------------------------------------------------------- 074 @Override 075 protected void initFromXMLTag(XMLTag inXMLTag) 076 { 077 inXMLTag.verifyTagName(getTagName()); 078 079 if (CollectionUtil.hasValues(inXMLTag.getAttributes())) 080 { 081 for (XMLAttribute attr : inXMLTag.getAttributes()) 082 { 083 setAttribute(attr.clone()); 084 } 085 } 086 087 List subtagsAndContent = inXMLTag.getContentPlusSubtagList(); 088 if (CollectionUtil.hasValues(subtagsAndContent)) 089 { 090 for (Object object : subtagsAndContent) 091 { 092 if (object instanceof XMLTag) 093 { 094 XMLTag subtag = (XMLTag) object; 095 if (subtag.getTagName().equals(RDF.RDF.getLocalName())) 096 { 097 addSubtag(new RDF(subtag)); 098 } 099 else 100 { 101 addSubtag(subtag); 102 } 103 } 104 else 105 { 106 addContent((String)object); 107 } 108 } 109 } 110 } 111}