| 1 | // |
| 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 |
| 3 | // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> |
| 4 | // Any modifications to this file will be lost upon recompilation of the source schema. |
| 5 | // Generated on: 2014.02.21 at 04:13:17 AM CET |
| 6 | // |
| 7 | |
| 8 | |
| 9 | package org.jomc.model; |
| 10 | |
| 11 | import java.util.ArrayList; |
| 12 | import java.util.Iterator; |
| 13 | import java.util.List; |
| 14 | import javax.annotation.Generated; |
| 15 | import javax.xml.bind.annotation.XmlAccessType; |
| 16 | import javax.xml.bind.annotation.XmlAccessorType; |
| 17 | import javax.xml.bind.annotation.XmlAttribute; |
| 18 | import javax.xml.bind.annotation.XmlElement; |
| 19 | import javax.xml.bind.annotation.XmlType; |
| 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; |
| 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * List of texts. |
| 26 | * |
| 27 | * <p>Java class for Texts complex type. |
| 28 | * |
| 29 | * <p>The following schema fragment specifies the expected content contained within this class. |
| 30 | * |
| 31 | * <pre> |
| 32 | * <complexType name="Texts"> |
| 33 | * <complexContent> |
| 34 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
| 35 | * <sequence> |
| 36 | * <element ref="{http://jomc.org/model}text" maxOccurs="unbounded"/> |
| 37 | * </sequence> |
| 38 | * <attribute name="defaultLanguage" use="required" type="{http://jomc.org/model}Language" /> |
| 39 | * </restriction> |
| 40 | * </complexContent> |
| 41 | * </complexType> |
| 42 | * </pre> |
| 43 | * |
| 44 | * |
| 45 | */ |
| 46 | @XmlAccessorType(XmlAccessType.FIELD) |
| 47 | @XmlType(name = "Texts", namespace = "http://jomc.org/model", propOrder = { |
| 48 | "text" |
| 49 | }) |
| 50 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 51 | public class Texts implements Cloneable |
| 52 | { |
| 53 | |
| 54 | @XmlElement(namespace = "http://jomc.org/model", required = true) |
| 55 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 56 | protected List<Text> text; |
| 57 | @XmlAttribute(name = "defaultLanguage", required = true) |
| 58 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) |
| 59 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 60 | protected String defaultLanguage; |
| 61 | |
| 62 | /** |
| 63 | * Creates a new {@code Texts} instance. |
| 64 | * |
| 65 | */ |
| 66 | public Texts() { |
| 67 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 68 | super(); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Creates a new {@code Texts} instance by deeply copying a given {@code Texts} instance. |
| 73 | * |
| 74 | * |
| 75 | * @param o |
| 76 | * The instance to copy. |
| 77 | * @throws NullPointerException |
| 78 | * if {@code o} is {@code null}. |
| 79 | */ |
| 80 | public Texts(final Texts o) { |
| 81 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 82 | super(); |
| 83 | if (o == null) { |
| 84 | throw new NullPointerException("Cannot create a copy of 'Texts' from 'null'."); |
| 85 | } |
| 86 | // 'Text' collection. |
| 87 | if (o.text!= null) { |
| 88 | copyText(o.getText(), this.getText()); |
| 89 | } |
| 90 | // CBuiltinLeafInfo: java.lang.String |
| 91 | this.defaultLanguage = ((o.defaultLanguage == null)?null:o.getDefaultLanguage()); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Gets the value of the text property. |
| 96 | * |
| 97 | * <p> |
| 98 | * This accessor method returns a reference to the live list, |
| 99 | * not a snapshot. Therefore any modification you make to the |
| 100 | * returned list will be present inside the JAXB object. |
| 101 | * This is why there is not a <CODE>set</CODE> method for the text property. |
| 102 | * |
| 103 | * <p> |
| 104 | * For example, to add a new item, do as follows: |
| 105 | * <pre> |
| 106 | * getText().add(newItem); |
| 107 | * </pre> |
| 108 | * |
| 109 | * |
| 110 | * <p> |
| 111 | * Objects of the following type(s) are allowed in the list |
| 112 | * {@link Text } |
| 113 | * |
| 114 | * |
| 115 | */ |
| 116 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 117 | public List<Text> getText() { |
| 118 | if (text == null) { |
| 119 | text = new ArrayList<Text>(); |
| 120 | } |
| 121 | return this.text; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Default text of this list. |
| 126 | * |
| 127 | * @return |
| 128 | * possible object is |
| 129 | * {@link String } |
| 130 | * |
| 131 | */ |
| 132 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 133 | public String getDefaultLanguage() { |
| 134 | return defaultLanguage; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Sets the value of the defaultLanguage property. |
| 139 | * |
| 140 | * @param value |
| 141 | * allowed object is |
| 142 | * {@link String } |
| 143 | * |
| 144 | */ |
| 145 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 146 | public void setDefaultLanguage(String value) { |
| 147 | this.defaultLanguage = value; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Copies all values of property {@code Text} deeply. |
| 152 | * |
| 153 | * @param source |
| 154 | * The source to copy from. |
| 155 | * @param target |
| 156 | * The target to copy {@code source} to. |
| 157 | * @throws NullPointerException |
| 158 | * if {@code target} is {@code null}. |
| 159 | */ |
| 160 | @SuppressWarnings("unchecked") |
| 161 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 162 | private static void copyText(final List<Text> source, final List<Text> target) { |
| 163 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 164 | if ((source!= null)&&(!source.isEmpty())) { |
| 165 | for (final Iterator<?> it = source.iterator(); it.hasNext(); ) { |
| 166 | final Object next = it.next(); |
| 167 | if (next instanceof Text) { |
| 168 | // CClassInfo: org.jomc.model.Text |
| 169 | target.add(((Text) next).clone()); |
| 170 | continue; |
| 171 | } |
| 172 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
| 173 | throw new AssertionError((("Unexpected instance '"+ next)+"' for property 'Text' of class 'org.jomc.model.Texts'.")); |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Creates and returns a deep copy of this object. |
| 180 | * |
| 181 | * |
| 182 | * @return |
| 183 | * A deep copy of this object. |
| 184 | */ |
| 185 | @Override |
| 186 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2014-02-21T04:13:17+01:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") |
| 187 | public Texts clone() { |
| 188 | try { |
| 189 | { |
| 190 | // CC-XJC Version 2.0.1 Build 2012-03-02T12:09:12+0000 |
| 191 | final Texts clone = ((Texts) super.clone()); |
| 192 | // 'Text' collection. |
| 193 | if (this.text!= null) { |
| 194 | clone.text = null; |
| 195 | copyText(this.getText(), clone.getText()); |
| 196 | } |
| 197 | // CBuiltinLeafInfo: java.lang.String |
| 198 | clone.defaultLanguage = ((this.defaultLanguage == null)?null:this.getDefaultLanguage()); |
| 199 | return clone; |
| 200 | } |
| 201 | } catch (CloneNotSupportedException e) { |
| 202 | // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ |
| 203 | throw new AssertionError(e); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Gets a text for a given language from the list of texts. |
| 209 | * |
| 210 | * @param language The language of the text to return. |
| 211 | * |
| 212 | * @return The first matching text or the default text, if no such text is found. |
| 213 | * |
| 214 | * @throws NullPointerException if {@code language} is {@code null}. |
| 215 | * |
| 216 | * @see #getText() |
| 217 | * @see #getDefaultLanguage() |
| 218 | * @see Text#getLanguage() |
| 219 | */ |
| 220 | public Text getText( final String language ) |
| 221 | { |
| 222 | if ( language == null ) |
| 223 | { |
| 224 | throw new NullPointerException( "language" ); |
| 225 | } |
| 226 | |
| 227 | Text defaultText = null; |
| 228 | |
| 229 | for ( int i = 0, s0 = this.getText().size(); i < s0; i++ ) |
| 230 | { |
| 231 | final Text t = this.getText().get( i ); |
| 232 | |
| 233 | if ( t.getLanguage().equalsIgnoreCase( this.getDefaultLanguage() ) ) |
| 234 | { |
| 235 | defaultText = t; |
| 236 | } |
| 237 | if ( t.getLanguage().equalsIgnoreCase( language ) ) |
| 238 | { |
| 239 | return t; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | return defaultText; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Gets a text for a given locale from the list of texts. |
| 248 | * |
| 249 | * @param locale The locale of the text to return. |
| 250 | * |
| 251 | * @return The first matching text or the default text, if no such text is found. |
| 252 | * |
| 253 | * @throws NullPointerException if {@code locale} is {@code null}. |
| 254 | * |
| 255 | * @see #getText() |
| 256 | * @see #getDefaultLanguage() |
| 257 | * @see Text#getLanguage() |
| 258 | * |
| 259 | * @since 1.4 |
| 260 | */ |
| 261 | public Text getText( final java.util.Locale locale ) |
| 262 | { |
| 263 | if ( locale == null ) |
| 264 | { |
| 265 | throw new NullPointerException( "locale" ); |
| 266 | } |
| 267 | |
| 268 | Text defaultText = null; |
| 269 | |
| 270 | for ( int i = 0, s0 = this.getText().size(); i < s0; i++ ) |
| 271 | { |
| 272 | final Text t = this.getText().get( i ); |
| 273 | |
| 274 | if ( t.getLanguage().equalsIgnoreCase( this.getDefaultLanguage() ) ) |
| 275 | { |
| 276 | defaultText = t; |
| 277 | } |
| 278 | if ( t.getLanguage().equalsIgnoreCase( locale.getLanguage() ) ) |
| 279 | { |
| 280 | return t; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return defaultText; |
| 285 | } |
| 286 | |
| 287 | } |