001 // 002 // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 003 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 004 // Any modifications to this file will be lost upon recompilation of the source schema. 005 // Generated on: 2009.12.07 at 03:06:36 AM UTC 006 // 007 008 009 package org.jomc.model; 010 011 import java.util.ArrayList; 012 import java.util.Iterator; 013 import java.util.List; 014 import javax.annotation.Generated; 015 import javax.xml.bind.annotation.XmlAccessType; 016 import javax.xml.bind.annotation.XmlAccessorType; 017 import javax.xml.bind.annotation.XmlAttribute; 018 import javax.xml.bind.annotation.XmlElement; 019 import javax.xml.bind.annotation.XmlType; 020 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 021 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 022 023 024 /** 025 * List of texts. 026 * 027 * <p>Java class for Texts complex type. 028 * 029 * <p>The following schema fragment specifies the expected content contained within this class. 030 * 031 * <pre> 032 * <complexType name="Texts"> 033 * <complexContent> 034 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 035 * <sequence> 036 * <element ref="{http://jomc.org/model}text" maxOccurs="unbounded"/> 037 * </sequence> 038 * <attribute name="defaultLanguage" use="required" type="{http://jomc.org/model}Language" /> 039 * </restriction> 040 * </complexContent> 041 * </complexType> 042 * </pre> 043 * 044 * 045 */ 046 @XmlAccessorType(XmlAccessType.FIELD) 047 @XmlType(name = "Texts", propOrder = { 048 "text" 049 }) 050 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 051 public class Texts implements Cloneable 052 { 053 054 @XmlElement(required = true) 055 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 056 protected List<Text> text; 057 @XmlAttribute(required = true) 058 @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 059 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 060 protected String defaultLanguage; 061 062 /** 063 * Creates a new {@code Texts} instance. 064 * 065 */ 066 public Texts() { 067 // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 068 super(); 069 } 070 071 /** 072 * Creates a new {@code Texts} instance by deeply copying a given {@code Texts} instance. 073 * 074 * 075 * @param o 076 * The instance to copy. 077 * @throws NullPointerException 078 * if {@code o} is {@code null}. 079 */ 080 public Texts(final Texts o) { 081 // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 082 super(); 083 if (o == null) { 084 throw new NullPointerException("Cannot create a copy of 'Texts' from 'null'."); 085 } 086 // 'Text' collection. 087 copyText(o.getText(), getText()); 088 // CBuiltinLeafInfo: java.lang.String 089 this.defaultLanguage = o.getDefaultLanguage(); 090 } 091 092 /** 093 * Gets the value of the text property. 094 * 095 * <p> 096 * This accessor method returns a reference to the live list, 097 * not a snapshot. Therefore any modification you make to the 098 * returned list will be present inside the JAXB object. 099 * This is why there is not a <CODE>set</CODE> method for the text property. 100 * 101 * <p> 102 * For example, to add a new item, do as follows: 103 * <pre> 104 * getText().add(newItem); 105 * </pre> 106 * 107 * 108 * <p> 109 * Objects of the following type(s) are allowed in the list 110 * {@link Text } 111 * 112 * 113 */ 114 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 115 public List<Text> getText() { 116 if (text == null) { 117 text = new ArrayList<Text>(); 118 } 119 return this.text; 120 } 121 122 /** 123 * Default text of this list. 124 * 125 * @return 126 * possible object is 127 * {@link String } 128 * 129 */ 130 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 131 public String getDefaultLanguage() { 132 return defaultLanguage; 133 } 134 135 /** 136 * Sets the value of the defaultLanguage property. 137 * 138 * @param value 139 * allowed object is 140 * {@link String } 141 * 142 */ 143 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 144 public void setDefaultLanguage(String value) { 145 this.defaultLanguage = value; 146 } 147 148 /** 149 * Copies all values of property {@code Text} deeply. 150 * 151 * @param target 152 * The target to copy {@code source} to. 153 * @param source 154 * The source to copy from. 155 * @throws NullPointerException 156 * if {@code source} or {@code target} is {@code null}. 157 */ 158 @SuppressWarnings("unchecked") 159 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 160 private static void copyText(final List<Text> source, final List<Text> target) { 161 // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 162 if (!source.isEmpty()) { 163 for (Iterator it = source.iterator(); it.hasNext(); ) { 164 final Object next = it.next(); 165 if (next instanceof Text) { 166 // CClassInfo: org.jomc.model.Text 167 target.add(((Text) next).clone()); 168 continue; 169 } 170 // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ 171 throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Text' of class 'org.jomc.model.Texts'.")); 172 } 173 } 174 } 175 176 /** 177 * Creates and returns a deep copy of this object. 178 * 179 * 180 * @return 181 * A deep copy of this object. 182 */ 183 @Override 184 @Generated(value = "com.sun.tools.xjc.Driver", date = "2009-12-07T03:06:36+00:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-833") 185 public Texts clone() { 186 // CC-XJC Version 1.2 Build 2009-11-15T21:50:02+0000 187 return new Texts(this); 188 } 189 190 /** 191 * Gets a text for a given language. 192 * 193 * @param language The language of the text to return. 194 * 195 * @return The text with language {@code language} or the default text, if 196 * no text matching {@code language} is found. 197 * 198 * @throws NullPointerException if {@code language} is {@code null}. 199 */ 200 public Text getText( final String language ) 201 { 202 if ( language == null ) 203 { 204 throw new NullPointerException( "language" ); 205 } 206 207 Text defaultText = null; 208 209 for ( Text t : this.getText() ) 210 { 211 if ( t.getLanguage().equals( this.getDefaultLanguage() ) ) 212 { 213 defaultText = t; 214 } 215 if ( t.getLanguage().equals( language ) ) 216 { 217 return t; 218 } 219 } 220 221 return defaultText; 222 } 223 224 225 }