OSDN Git Service

Set optimal mime types and executable settings.
[mikumikustudio/MikuMikuStudio.git] / src / com / jmex / xml / types / SchemaAnyURI.java
1 /**
2  * SchemaAnyURI.java
3  *
4  * This file was generated by XMLSpy 2007sp2 Enterprise Edition.
5  *
6  * YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
7  * OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
8  *
9  * Refer to the XMLSpy Documentation for further details.
10  * http://www.altova.com/xmlspy
11  */
12
13
14 package com.jmex.xml.types;
15
16 import java.net.URI;
17
18 public class SchemaAnyURI implements SchemaType {
19   protected URI value;
20   protected boolean isempty;
21   protected boolean isnull;
22
23   // construction
24   public SchemaAnyURI() {
25     setEmpty();
26   }
27
28   public SchemaAnyURI(SchemaAnyURI newvalue) {
29     value = newvalue.value;
30     isempty = newvalue.isempty;
31     isnull = newvalue.isnull;
32   }
33
34   public SchemaAnyURI(URI newvalue) {
35     setValue( newvalue );
36   }
37
38   public SchemaAnyURI(String newvalue) {
39     parse( newvalue );
40   }
41
42   public SchemaAnyURI(SchemaType newvalue) {
43     assign( newvalue );
44   }
45
46   // getValue, setValue
47   public URI getValue() {
48     return value;
49   }
50
51   public void setValue(URI newvalue) {
52     if( newvalue == null ) {
53       isempty = true;
54       isnull = true;
55     }
56     else {
57       isnull = false;
58       isempty = false;
59       value = newvalue;
60     }
61   }
62
63   public void parse(String s) {
64           
65         String newvalue = SchemaNormalizedString.normalize(SchemaNormalizedString.WHITESPACE_COLLAPSE, s);
66
67     if( newvalue == null )
68       setNull();
69     else if( newvalue.length() == 0)
70       setEmpty();
71     else {
72       setNull();
73       try {
74         value = URI.create(newvalue);
75       }
76       catch (IllegalArgumentException e) {
77         throw new StringParseException(e);
78       }
79       isnull = false;
80       isempty = false;
81     }
82   }
83
84   public void assign(SchemaType newvalue) {
85     if( newvalue == null || newvalue.isNull() )
86       setNull();
87     else if( newvalue.isEmpty() )
88       setEmpty();
89     else {
90       if( newvalue instanceof SchemaString )
91         parse(newvalue.toString());
92       else if( newvalue instanceof SchemaAnyURI)
93         setValue(((SchemaAnyURI)newvalue).value);
94       else
95         throw new TypesIncompatibleException( newvalue, this );
96     }
97   }
98
99   public void setNull() {
100     isnull = true;
101     isempty = true;
102     value = null;
103   }
104
105   public void setEmpty() {
106     parse("http://www.altova.com/language_select.html");
107   }
108
109   // further
110   public int hashCode() {
111     return value.hashCode();
112   }
113
114   public boolean equals(Object obj) {
115     if (! (obj instanceof SchemaAnyURI))
116       return false;
117     return value.equals(( (SchemaAnyURI) obj).value);
118   }
119
120   public Object clone() {
121     return new SchemaAnyURI(this);
122   }
123
124   public String toString() {
125     if( isempty || isnull || value == null )
126       return "";
127     return value.toString();
128   }
129
130   public int length() {
131     return value.toString().length();
132   }
133
134   public boolean booleanValue() {
135     return (value != null && value.toString().length() != 0);
136   }
137
138   public boolean isEmpty() {
139     return isempty;
140   }
141
142   public boolean isNull() {
143     return isnull;
144   }
145
146   public int compareTo(Object obj) {
147     return compareTo( (SchemaAnyURI) obj);
148   }
149
150   public int compareTo(SchemaAnyURI obj) {
151     return toString().compareTo( obj.toString() );
152   }
153 }