You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/02/21 21:34:01 UTC
svn commit: r1886771 [5/8] - in /xmlbeans/trunk: ./
src/main/java/org/apache/xmlbeans/
src/main/java/org/apache/xmlbeans/impl/schema/
src/main/java/org/apache/xmlbeans/impl/tool/
src/main/java/org/apache/xmlbeans/impl/values/ src/main/multimodule/java9...
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java?rev=1886771&r1=1886770&r2=1886771&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlUnsignedShort.java Sun Feb 21 21:34:00 2021
@@ -15,6 +15,8 @@
package org.apache.xmlbeans;
+import org.apache.xmlbeans.impl.schema.XmlObjectFactory;
+
/**
* Corresponds to the XML Schema
* <a target="_blank" href="http://www.w3.org/TR/xmlschema-2/#unsignedShort">xs:unsignedShort</a> type.
@@ -25,10 +27,12 @@ package org.apache.xmlbeans;
* Convertible to a Java int.
*/
public interface XmlUnsignedShort extends XmlUnsignedInt {
+ XmlObjectFactory<XmlUnsignedShort> Factory = new XmlObjectFactory<>("_BI_unsignedShort");
+
/**
* The constant {@link SchemaType} object representing this schema type.
*/
- SchemaType type = XmlBeans.getBuiltinTypeSystem().typeForHandle("_BI_unsignedShort");
+ SchemaType type = Factory.getType();
/**
* Returns this value as an int
@@ -39,134 +43,5 @@ public interface XmlUnsignedShort extend
* Sets this value as an int
*/
void setIntValue(int v);
-
- /**
- * A class with methods for creating instances
- * of {@link XmlUnsignedShort}.
- */
- final class Factory {
- /**
- * Creates an empty instance of {@link XmlUnsignedShort}
- */
- public static XmlUnsignedShort newInstance() {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().newInstance(type, null);
- }
-
- /**
- * Creates an empty instance of {@link XmlUnsignedShort}
- */
- public static XmlUnsignedShort newInstance(org.apache.xmlbeans.XmlOptions options) {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().newInstance(type, options);
- }
-
- /**
- * Creates an immutable {@link XmlUnsignedShort} value
- */
- public static XmlUnsignedShort newValue(Object obj) {
- return (XmlUnsignedShort) type.newValue(obj);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a String. For example: "<code><xml-fragment>12345</xml-fragment></code>".
- */
- public static XmlUnsignedShort parse(java.lang.String s) throws org.apache.xmlbeans.XmlException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(s, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a String. For example: "<code><xml-fragment>12345</xml-fragment></code>".
- */
- public static XmlUnsignedShort parse(java.lang.String s, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(s, type, options);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a File.
- */
- public static XmlUnsignedShort parse(java.io.File f) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(f, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a File.
- */
- public static XmlUnsignedShort parse(java.io.File f, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(f, type, options);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a URL.
- */
- public static XmlUnsignedShort parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(u, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a URL.
- */
- public static XmlUnsignedShort parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(u, type, options);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from an InputStream.
- */
- public static XmlUnsignedShort parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(is, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from an InputStream.
- */
- public static XmlUnsignedShort parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(is, type, options);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a Reader.
- */
- public static XmlUnsignedShort parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(r, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a Reader.
- */
- public static XmlUnsignedShort parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(r, type, options);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a DOM Node.
- */
- public static XmlUnsignedShort parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(node, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from a DOM Node.
- */
- public static XmlUnsignedShort parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(node, type, options);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from an XMLStreamReader.
- */
- public static XmlUnsignedShort parse(javax.xml.stream.XMLStreamReader xsr) throws org.apache.xmlbeans.XmlException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(xsr, type, null);
- }
-
- /**
- * Parses a {@link XmlUnsignedShort} fragment from an XMLStreamReader.
- */
- public static XmlUnsignedShort parse(javax.xml.stream.XMLStreamReader xsr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
- return (XmlUnsignedShort) XmlBeans.getContextTypeLoader().parse(xsr, type, options);
- }
-
- private Factory() {
- // No instance of this class allowed
- }
- }
}
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/AbstractDocumentFactory.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/AbstractDocumentFactory.java?rev=1886771&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/AbstractDocumentFactory.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/AbstractDocumentFactory.java Sun Feb 21 21:34:00 2021
@@ -0,0 +1,97 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.schema;
+
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.w3c.dom.Node;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+
+@SuppressWarnings("unchecked")
+public class AbstractDocumentFactory<T> extends ElementFactory<T> {
+ public AbstractDocumentFactory(SchemaTypeSystem typeSystem, String typeHandle) {
+ super(typeSystem, typeHandle);
+ }
+
+ /**
+ * @param xmlAsString the string value to parse
+ */
+ public T parse(String xmlAsString) throws XmlException {
+ return (T) getTypeLoader().parse(xmlAsString, getType(), null);
+ }
+
+ public T parse(String xmlAsString, XmlOptions options) throws XmlException {
+ return (T) getTypeLoader().parse(xmlAsString, getType(), options);
+ }
+
+ /**
+ * @param file the file from which to load an xml document
+ */
+ public T parse(File file) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(file, getType(), null);
+ }
+
+ public T parse(File file, XmlOptions options) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(file, getType(), options);
+ }
+
+ public T parse(URL u) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(u, getType(), null);
+ }
+
+ public T parse(URL u, XmlOptions options) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(u, getType(), options);
+ }
+
+ public T parse(InputStream is) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(is, getType(), null);
+ }
+
+ public T parse(InputStream is, XmlOptions options) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(is, getType(), options);
+ }
+
+ public T parse(Reader r) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(r, getType(), null);
+ }
+
+ public T parse(Reader r, XmlOptions options) throws XmlException, IOException {
+ return (T) getTypeLoader().parse(r, getType(), options);
+ }
+
+ public T parse(XMLStreamReader sr) throws XmlException {
+ return (T) getTypeLoader().parse(sr, getType(), null);
+ }
+
+ public T parse(XMLStreamReader sr, XmlOptions options) throws XmlException {
+ return (T) getTypeLoader().parse(sr, getType(), options);
+ }
+
+ public T parse(Node node) throws XmlException {
+ return (T) getTypeLoader().parse(node, getType(), null);
+ }
+
+ public T parse(Node node, XmlOptions options) throws XmlException {
+ return (T) getTypeLoader().parse(node, getType(), options);
+ }
+}
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/DocumentFactory.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/DocumentFactory.java?rev=1886771&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/DocumentFactory.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/DocumentFactory.java Sun Feb 21 21:34:00 2021
@@ -0,0 +1,34 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.schema;
+
+import org.apache.xmlbeans.SchemaTypeSystem;
+
+@SuppressWarnings("unchecked")
+public class DocumentFactory<T> extends AbstractDocumentFactory<T> {
+ public DocumentFactory(SchemaTypeSystem typeSystem, String typeHandle) {
+ super(typeSystem, typeHandle);
+ }
+
+ public T newInstance() {
+ return (T) getTypeLoader().newInstance(getType(), null);
+ }
+
+
+ public T newInstance(org.apache.xmlbeans.XmlOptions options) {
+ return (T) getTypeLoader().newInstance(getType(), options);
+ }
+}
Added: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/ElementFactory.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/ElementFactory.java?rev=1886771&view=auto
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/ElementFactory.java (added)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/schema/ElementFactory.java Sun Feb 21 21:34:00 2021
@@ -0,0 +1,47 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.schema;
+
+import org.apache.xmlbeans.SchemaType;
+import org.apache.xmlbeans.SchemaTypeSystem;
+import org.apache.xmlbeans.XmlOptions;
+
+@SuppressWarnings("unchecked")
+public class ElementFactory<T> {
+ private final SchemaType type;
+ private final SchemaTypeSystem typeSystem;
+
+ public ElementFactory(SchemaTypeSystem typeSystem, String typeHandle) {
+ this.typeSystem = typeSystem;
+ this.type = (SchemaType)typeSystem.resolveHandle(typeHandle);
+ }
+
+ public SchemaType getType() {
+ return type;
+ }
+
+ public SchemaTypeSystem getTypeLoader() {
+ return typeSystem;
+ }
+
+ public T newInstance() {
+ return (T) getTypeLoader().newInstance(type, null);
+ }
+
+ public T newInstance(XmlOptions options) {
+ return (T) getTypeLoader().newInstance(type, options);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org