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 2020/09/17 00:04:39 UTC
svn commit: r1881778 [10/10] - in /xmlbeans/trunk: ./
src/main/java/org/apache/xmlbeans/
src/main/java/org/apache/xmlbeans/impl/common/
src/main/java/org/apache/xmlbeans/impl/schema/
src/main/java/org/apache/xmlbeans/impl/store/ src/main/java/org/apach...
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java?rev=1881778&r1=1881777&r2=1881778&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/tool/XMLBean.java Thu Sep 17 00:04:39 2020
@@ -15,28 +15,27 @@
package org.apache.xmlbeans.impl.tool;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Reference;
-import org.apache.tools.ant.taskdefs.MatchingTask;
-import org.apache.tools.ant.taskdefs.Javac;
-import org.apache.tools.ant.taskdefs.Jar;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Jar;
+import org.apache.tools.ant.taskdefs.Javac;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+import org.apache.xmlbeans.XmlError;
+import org.apache.xmlbeans.impl.common.IOUtil;
import java.io.File;
-import java.io.StringWriter;
import java.io.PrintWriter;
-import java.util.*;
+import java.io.StringWriter;
import java.net.URI;
-
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.impl.common.IOUtil;
+import java.util.*;
/**
* Modeled after Ant's javac and zip tasks.
- *
+ * <p>
* Schema files to process, or directories of schema files, are set with the 'schema'
* attribute, and can be filtered with 'includes' and 'excludes'.
* Alternatively, one or more nested <fileset> elements can specify the
@@ -46,104 +45,93 @@ import org.apache.xmlbeans.impl.common.I
* for instructions on FileSets if you are unfamiliar with their usage.
*/
-public class XMLBean extends MatchingTask
-{
- private ArrayList schemas = new ArrayList();
-
- private Set mdefnamespaces;
-
- private Path classpath;
-
- private File destfile,
- schema,
- srcgendir,
- classgendir;
-
- private boolean quiet,
- verbose,
- debug,
- optimize,
- download,
- srconly,
- noupa,
- nopvr,
- noann,
- novdoc,
- noext = false,
- failonerror = true,
- fork = true,
- includeAntRuntime = true,
- noSrcRegen,
- includeJavaRuntime = false,
- nowarn = false;
-
- private String typesystemname,
- forkedExecutable,
- compiler,
- debugLevel,
- memoryInitialSize,
- memoryMaximumSize,
- catalog,
- javasource,
- repackage;
+public class XMLBean extends MatchingTask {
+ private final List<FileSet> schemas = new ArrayList<>();
+
+ private Set<String> mdefnamespaces;
+
+ private Path classpath;
+
+ private File destfile,
+ schema,
+ srcgendir,
+ classgendir;
+
+ private boolean quiet,
+ verbose,
+ debug,
+ optimize,
+ download,
+ srconly,
+ noupa,
+ nopvr,
+ noann,
+ novdoc,
+ noext = false,
+ failonerror = true,
+ fork = true,
+ includeAntRuntime = true,
+ noSrcRegen,
+ includeJavaRuntime = false,
+ nowarn = false;
+
+ private String typesystemname,
+ forkedExecutable,
+ compiler,
+ debugLevel,
+ memoryInitialSize,
+ memoryMaximumSize,
+ catalog,
+ repackage;
- private List extensions = new ArrayList();
+ private final List<Extension> extensions = new ArrayList<>();
- private HashMap _extRouter = new HashMap(5);
+ private final Map<String, Set<File>> _extRouter = new HashMap<>(5);
private static final String XSD = ".xsd",
- WSDL = ".wsdl",
- JAVA = ".java",
- XSDCONFIG = ".xsdconfig";
+ WSDL = ".wsdl",
+ JAVA = ".java",
+ XSDCONFIG = ".xsdconfig";
- public void execute() throws BuildException
- {
+ public void execute() throws BuildException {
/* VALIDATION */
//required
if (schemas.size() == 0
&& schema == null
- && fileset.getDir(project) == null)
- {
+ && fileset.getDir(project) == null) {
String msg = "The 'schema' or 'dir' attribute or a nested fileset is required.";
- if (failonerror)
+ if (failonerror) {
throw new BuildException(msg);
- else
- {
+ } else {
log(msg, Project.MSG_ERR);
return;
}
}
- _extRouter.put(XSD, new HashSet());
- _extRouter.put(WSDL, new HashSet());
- _extRouter.put(JAVA, new HashSet());
- _extRouter.put(XSDCONFIG, new HashSet());
+ _extRouter.put(XSD, new HashSet<>());
+ _extRouter.put(WSDL, new HashSet<>());
+ _extRouter.put(JAVA, new HashSet<>());
+ _extRouter.put(XSDCONFIG, new HashSet<>());
File theBasedir = schema;
- if (schema != null)
- {
- if (schema.isDirectory())
- {
+ if (schema != null) {
+ if (schema.isDirectory()) {
FileScanner scanner = getDirectoryScanner(schema);
String[] paths = scanner.getIncludedFiles();
processPaths(paths, scanner.getBasedir());
- }
- else
- {
+ } else {
theBasedir = schema.getParentFile();
- processPaths(new String[] { schema.getName() }, theBasedir);
+ processPaths(new String[]{schema.getName()}, theBasedir);
}
}
- if (fileset.getDir(project) != null)
+ if (fileset.getDir(project) != null) {
schemas.add(fileset);
+ }
- Iterator si = schemas.iterator();
- while (si.hasNext())
- {
- FileSet fs = (FileSet) si.next();
+ for (FileSet fs : schemas) {
FileScanner scanner = fs.getDirectoryScanner(project);
File basedir = scanner.getBasedir();
String[] paths = scanner.getIncludedFiles();
@@ -151,54 +139,55 @@ public class XMLBean extends MatchingTas
processPaths(paths, basedir);
}
- Set xsdList = (Set) _extRouter.get(XSD);
- Set wsdlList = (Set) _extRouter.get(WSDL);
+ Set<File> xsdList = _extRouter.get(XSD);
+ Set<File> wsdlList = _extRouter.get(WSDL);
- if (xsdList.size() + wsdlList.size() == 0)
- {
+ if (xsdList.size() + wsdlList.size() == 0) {
log("Could not find any xsd or wsdl files to process.", Project.MSG_WARN);
return;
}
//optional
- Set javaList = (Set) _extRouter.get(JAVA);
- Set xsdconfigList = (Set) _extRouter.get(XSDCONFIG);
+ Set<File> javaList = _extRouter.get(JAVA);
+ Set<File> xsdconfigList = _extRouter.get(XSDCONFIG);
- if (srcgendir == null && srconly)
+ if (srcgendir == null && srconly) {
srcgendir = classgendir;
+ }
- if (destfile == null && classgendir == null && ! srconly)
+ if (destfile == null && classgendir == null && !srconly) {
destfile = new File("xmltypes.jar");
+ }
- if (verbose)
+ if (verbose) {
quiet = false;
+ }
/* EXECUTION */
- File[] xsdArray = (File[]) xsdList.toArray(new File[xsdList.size()]);
- File[] wsdlArray = (File[]) wsdlList.toArray(new File[wsdlList.size()]);
- File[] javaArray = (File[]) javaList.toArray(new File[javaList.size()]);
- File[] xsdconfigArray = (File[]) xsdconfigList.toArray(new File[xsdconfigList.size()]);
+ File[] xsdArray = xsdList.toArray(new File[0]);
+ File[] wsdlArray = wsdlList.toArray(new File[0]);
+ File[] javaArray = javaList.toArray(new File[0]);
+ File[] xsdconfigArray = xsdconfigList.toArray(new File[0]);
ErrorLogger err = new ErrorLogger(verbose);
boolean success = false;
- try
- {
+ try {
// create a temp directory
File tmpdir = null;
- if (srcgendir == null || classgendir == null)
- {
+ if (srcgendir == null || classgendir == null) {
tmpdir = SchemaCodeGenerator.createTempDir();
}
- if (srcgendir == null)
+ if (srcgendir == null) {
srcgendir = IOUtil.createDir(tmpdir, "src");
- if (classgendir == null)
+ }
+ if (classgendir == null) {
classgendir = IOUtil.createDir(tmpdir, "classes");
+ }
// use the system classpath if user didn't provide any
- if (classpath == null)
- {
+ if (classpath == null) {
classpath = new Path(project);
classpath.concatSystemClasspath();
}
@@ -209,8 +198,9 @@ public class XMLBean extends MatchingTas
String[] paths = classpath.list();
File[] cp = new File[paths.length];
- for (int i = 0; i < paths.length; i++)
+ for (int i = 0; i < paths.length; i++) {
cp[i] = new File(paths[i]);
+ }
// generate the source
SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
@@ -238,7 +228,6 @@ public class XMLBean extends MatchingTas
params.setNoAnn(noann);
params.setNoVDoc(novdoc);
params.setNoExt(noext);
- params.setJavaSource(javasource);
params.setRepackage(repackage);
success = SchemaCompiler.compile(params);
@@ -250,39 +239,39 @@ public class XMLBean extends MatchingTas
javac.setProject(project);
javac.setTaskName(getTaskName());
javac.setClasspath(classpath);
- if (compiler != null) javac.setCompiler(compiler);
+ if (compiler != null) {
+ javac.setCompiler(compiler);
+ }
javac.setDebug(debug);
- if (debugLevel != null) javac.setDebugLevel(debugLevel);
+ if (debugLevel != null) {
+ javac.setDebugLevel(debugLevel);
+ }
javac.setDestdir(classgendir);
javac.setExecutable(forkedExecutable);
javac.setFailonerror(failonerror);
javac.setFork(fork);
- if (javasource != null)
- {
- javac.setSource(javasource);
- javac.setTarget(javasource);
- }
- else
- {
- javac.setSource("1.4");
- javac.setTarget("1.4");
- }
+ javac.setSource("1.8");
+ javac.setTarget("1.8");
javac.setIncludeantruntime(includeAntRuntime);
javac.setIncludejavaruntime(includeJavaRuntime);
javac.setNowarn(nowarn);
javac.setSrcdir(new Path(project, srcgendir.getAbsolutePath()));
- if (memoryInitialSize != null) javac.setMemoryInitialSize(memoryInitialSize);
- if (memoryMaximumSize != null) javac.setMemoryMaximumSize(memoryMaximumSize);
+ if (memoryInitialSize != null) {
+ javac.setMemoryInitialSize(memoryInitialSize);
+ }
+ if (memoryMaximumSize != null) {
+ javac.setMemoryMaximumSize(memoryMaximumSize);
+ }
javac.setOptimize(optimize);
javac.setVerbose(verbose);
javac.execute();
long finish = System.currentTimeMillis();
- if (!quiet)
- log("Time to compile code: " + ((double)(finish - start) / 1000.0) + " seconds");
+ if (!quiet) {
+ log("Time to compile code: " + ((double) (finish - start) / 1000.0) + " seconds");
+ }
- if (destfile != null)
- {
+ if (destfile != null) {
// jar the compiled classes
Jar jar = new Jar();
jar.setProject(project);
@@ -296,17 +285,14 @@ public class XMLBean extends MatchingTas
if (tmpdir != null) {
SchemaCodeGenerator.tryHardToDelete(tmpdir);
}
- }
- catch (BuildException e)
- {
+ } catch (BuildException e) {
// re-throw anything thrown from javac or jar task
throw e;
- }
- catch (Throwable e)
- {
+ } catch (Throwable e) {
//interrupted means cancel
- if (e instanceof InterruptedException || failonerror)
+ if (e instanceof InterruptedException || failonerror) {
throw new BuildException(e);
+ }
log("Exception while building schemas: " + e.getMessage(), Project.MSG_ERR);
StringWriter sw = new StringWriter();
@@ -314,36 +300,32 @@ public class XMLBean extends MatchingTas
log(sw.toString(), Project.MSG_VERBOSE);
}
- if (!success && failonerror)
+ if (!success && failonerror) {
throw new BuildException(); //stop the build
+ }
}
- private void processPaths(String[] paths, File baseDir)
- {
- for (int i = 0; i < paths.length; i++)
- {
- int dot = paths[i].lastIndexOf('.');
- if (dot > -1)
- {
- String path = paths[i];
- String possExt = path.substring(dot).toLowerCase();
- Set set = (Set) _extRouter.get(possExt);
+ private void processPaths(String[] paths, File baseDir) {
+ for (String s : paths) {
+ int dot = s.lastIndexOf('.');
+ if (dot > -1) {
+ String possExt = s.substring(dot).toLowerCase();
+ Set<File> set = _extRouter.get(possExt);
- if (set != null)
- set.add(new File(baseDir, path));
+ if (set != null) {
+ set.add(new File(baseDir, s));
+ }
}
}
}
- public void addFileset(FileSet fileset)
- {
+ public void addFileset(FileSet fileset) {
schemas.add(fileset);
}
/////////////////////////////
//Getter/Setters
- public File getSchema()
- {
+ public File getSchema() {
return schema;
}
@@ -351,10 +333,10 @@ public class XMLBean extends MatchingTas
* A file that points to either an individual schema file or a directory of files.
* It is optional only if one or more <fileset> elements are nested in this
* task.
+ *
* @param schema Required, unless a fileset element is nested.
*/
- public void setSchema(File schema)
- {
+ public void setSchema(File schema) {
this.schema = schema;
}
@@ -362,14 +344,15 @@ public class XMLBean extends MatchingTas
* The classpath to use if schemas in the fileset import definitions that are
* supplied by other compiled xml beans JAR files, or if .java files are in the
* schema fileset.
+ *
* @param classpath Optional.
*/
- public void setClasspath(Path classpath)
- {
- if (this.classpath != null)
+ public void setClasspath(Path classpath) {
+ if (this.classpath != null) {
this.classpath.append(classpath);
- else
+ } else {
this.classpath = classpath;
+ }
}
/**
@@ -384,23 +367,22 @@ public class XMLBean extends MatchingTas
/**
* Adds a reference to a classpath defined elsewhere.
+ *
* @param classpathref Optional.
*/
- public void setClasspathRef(Reference classpathref)
- {
- if (classpath == null)
+ public void setClasspathRef(Reference classpathref) {
+ if (classpath == null) {
classpath = new Path(project);
+ }
classpath.createPath().setRefid(classpathref);
}
- public Path getClasspath()
- {
+ public Path getClasspath() {
return classpath;
}
- public File getDestfile()
- {
+ public File getDestfile() {
return destfile;
}
@@ -408,40 +390,38 @@ public class XMLBean extends MatchingTas
* Define the name of the jar file created. For instance, "myXMLBean.jar"
* will output the results of this task into a jar with the same name.
* Optional, defaults to "xmltypes.jar".
+ *
* @param destfile Optional.
*/
- public void setDestfile(File destfile)
- {
+ public void setDestfile(File destfile) {
this.destfile = destfile;
}
- public File getSrcgendir()
- {
+ public File getSrcgendir() {
return srcgendir;
}
/**
* Set a location to generate .java files into. Optional, defaults to
* a temp dir.
+ *
* @param srcgendir Optional.
*/
- public void setSrcgendir(File srcgendir)
- {
+ public void setSrcgendir(File srcgendir) {
this.srcgendir = srcgendir;
}
- public File getClassgendir()
- {
+ public File getClassgendir() {
return classgendir;
}
/**
* Set a location to generate .class files into. Optional, defaults to
* a temp dir.
+ *
* @param classgendir Optional.
*/
- public void setClassgendir(File classgendir)
- {
+ public void setClassgendir(File classgendir) {
this.classgendir = classgendir;
}
@@ -450,13 +430,11 @@ public class XMLBean extends MatchingTas
*
* @since Ant 1.5
*/
- public void setCompiler(String compiler)
- {
+ public void setCompiler(String compiler) {
this.compiler = compiler;
}
- public boolean isDownload()
- {
+ public boolean isDownload() {
return download;
}
@@ -464,10 +442,10 @@ public class XMLBean extends MatchingTas
* Set to true to permit the compiler to download URLs for imports
* and includes. Defaults to false, meaning all imports and includes
* must be copied locally.
+ *
* @param download Optional.
*/
- public void setDownload(boolean download)
- {
+ public void setDownload(boolean download) {
this.download = download;
}
@@ -478,46 +456,46 @@ public class XMLBean extends MatchingTas
this.optimize = optimize;
}
- /** Gets the optimize flag. */
+ /**
+ * Gets the optimize flag.
+ */
public boolean getOptimize() {
return optimize;
}
- public boolean isVerbose()
- {
+ public boolean isVerbose() {
return verbose;
}
/**
* Controls the amount of output. Defaults to true.
+ *
* @param verbose Optional.
*/
- public void setVerbose(boolean verbose)
- {
+ public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
- public boolean isQuiet()
- {
+ public boolean isQuiet() {
return quiet;
}
/**
* Controls the amount of output. Defaults to false.
+ *
* @param quiet Optional.
*/
- public void setQuiet(boolean quiet)
- {
+ public void setQuiet(boolean quiet) {
this.quiet = quiet;
}
- public boolean isDebug()
- {
+ public boolean isDebug() {
return debug;
}
/**
* Get the value of debugLevel.
+ *
* @return value of debugLevel.
*/
public String getDebugLevel() {
@@ -526,7 +504,7 @@ public class XMLBean extends MatchingTas
/**
* Keyword list to be appended to the -g command-line switch.
- *
+ * <p>
* This will be ignored by all implementations except modern
* and classic(ver >= 1.2). Legal values are none or a
* comma-separated list of the following keywords: lines, vars,
@@ -534,18 +512,18 @@ public class XMLBean extends MatchingTas
* will be appended to -g. If debug is not turned on, this attribute
* will be ignored.
*
- * @param v Value to assign to debugLevel.
+ * @param v Value to assign to debugLevel.
*/
- public void setDebugLevel(String v) {
+ public void setDebugLevel(String v) {
this.debugLevel = v;
}
/**
* Generate debugging symbols.
+ *
* @param debug Optional.
*/
- public void setDebug(boolean debug)
- {
+ public void setDebug(boolean debug) {
this.debug = debug;
}
@@ -572,29 +550,27 @@ public class XMLBean extends MatchingTas
return forkedExecutable;
}
- public boolean isSrconly()
- {
+ public boolean isSrconly() {
return srconly;
}
/**
* A value of true means that only source will be generated. Optional,
* default is false.
+ *
* @param srconly Optional.
*/
- public void setSrconly(boolean srconly)
- {
+ public void setSrconly(boolean srconly) {
this.srconly = srconly;
}
- public String getTypesystemname()
- {
+ public String getTypesystemname() {
return typesystemname;
}
/**
* One or more SchemaCompiler extensions can be passed in via the <extension> subelement.
- * Schema Compiler extensions must implement the interface com.xbean.too.SchemaCompilerExtension
+ * Schema Compiler extensions must implement the interface com.xbean.too.SchemaCompilerExtension
*/
public Extension createExtension() {
Extension e = new Extension();
@@ -607,28 +583,17 @@ public class XMLBean extends MatchingTas
* can be passed in via the <ignoreDuplicatesInNamespaces> subelement.
*/
public void setIgnoreDuplicatesInNamespaces(String namespaces) {
- mdefnamespaces = new HashSet();
+ mdefnamespaces = new HashSet<>();
StringTokenizer st = new StringTokenizer(namespaces, ",");
- while (st.hasMoreTokens())
- {
- String namespace = st.nextToken().trim();
- mdefnamespaces.add(namespace);
+ while (st.hasMoreTokens()) {
+ String namespace = st.nextToken().trim();
+ mdefnamespaces.add(namespace);
}
}
public String getIgnoreDuplicatesInNamespaces() {
- if (mdefnamespaces == null) {
- return null;
- }
- StringBuilder buf = new StringBuilder();
- Iterator i = mdefnamespaces.iterator();
- while (i.hasNext()) {
- buf.append((String)i.next());
- if (i.hasNext()) {
- buf.append(",");
- }
- }
- return buf.toString();
+ return mdefnamespaces == null ? null : String.join(",", mdefnamespaces);
+
}
/**
@@ -636,193 +601,158 @@ public class XMLBean extends MatchingTas
* generated in. Normally this should be left unspecified. None of
* the xml beans are generated in this package.
* <BR><BR>Use .xsdconfig files to modify xml bean package or class names.
+ *
* @param typesystemname Optional.
*/
- public void setTypesystemname(String typesystemname)
- {
+ public void setTypesystemname(String typesystemname) {
this.typesystemname = typesystemname;
}
- public boolean isFailonerror()
- {
+ public boolean isFailonerror() {
return failonerror;
}
/**
* Determines whether or not the ant target will continue if the XMLBean
* creation encounters a build error. Defaults to true. Optional.
+ *
* @param failonerror Optional.
*/
- public void setFailonerror(boolean failonerror)
- {
+ public void setFailonerror(boolean failonerror) {
this.failonerror = failonerror;
}
- public boolean isIncludeAntRuntime()
- {
+ public boolean isIncludeAntRuntime() {
return includeAntRuntime;
}
- public void setIncludeAntRuntime(boolean includeAntRuntime)
- {
+ public void setIncludeAntRuntime(boolean includeAntRuntime) {
this.includeAntRuntime = includeAntRuntime;
}
- public boolean isIncludeJavaRuntime()
- {
+ public boolean isIncludeJavaRuntime() {
return includeJavaRuntime;
}
- public void setIncludeJavaRuntime(boolean includeJavaRuntime)
- {
+ public void setIncludeJavaRuntime(boolean includeJavaRuntime) {
this.includeJavaRuntime = includeJavaRuntime;
}
- public boolean isNowarn()
- {
+ public boolean isNowarn() {
return nowarn;
}
- public void setNowarn(boolean nowarn)
- {
+ public void setNowarn(boolean nowarn) {
this.nowarn = nowarn;
}
- public boolean isNoSrcRegen()
- {
+ public boolean isNoSrcRegen() {
return noSrcRegen;
}
- public void setNoSrcRegen(boolean noSrcRegen)
- {
+ public void setNoSrcRegen(boolean noSrcRegen) {
this.noSrcRegen = noSrcRegen;
}
/**
* Set the initial memory size of the underlying javac process.
*/
- public String getMemoryInitialSize()
- {
+ public String getMemoryInitialSize() {
return memoryInitialSize;
}
- public void setMemoryInitialSize(String memoryInitialSize)
- {
+ public void setMemoryInitialSize(String memoryInitialSize) {
this.memoryInitialSize = memoryInitialSize;
}
/**
* Set the maximum memory size of the underlying javac process.
*/
- public String getMemoryMaximumSize()
- {
+ public String getMemoryMaximumSize() {
return memoryMaximumSize;
}
- public void setMemoryMaximumSize(String memoryMaximumSize)
- {
+ public void setMemoryMaximumSize(String memoryMaximumSize) {
this.memoryMaximumSize = memoryMaximumSize;
}
/**
* Do not enforce the unique particle attribution rule.
*/
- public void setNoUpa(boolean noupa)
- {
+ public void setNoUpa(boolean noupa) {
this.noupa = noupa;
}
- public boolean isNoUpa()
- {
+ public boolean isNoUpa() {
return noupa;
}
/**
* Do not enforce the particle valid (restriction) rule.
*/
- public void setNoPvr(boolean nopvr)
- {
+ public void setNoPvr(boolean nopvr) {
this.nopvr = nopvr;
}
- public boolean isNoPvr()
- {
+ public boolean isNoPvr() {
return nopvr;
}
/**
* Skip over schema <annotation%gt; elements.
*/
- public void setNoAnnotations(boolean noann)
- {
+ public void setNoAnnotations(boolean noann) {
this.noann = noann;
}
- public boolean isNoAnnotations()
- {
+ public boolean isNoAnnotations() {
return noann;
}
/**
* Do not validate the contents of schema <documentation> elements.
*/
- public void setNoValidateDoc(boolean novdoc)
- {
+ public void setNoValidateDoc(boolean novdoc) {
this.novdoc = novdoc;
}
- public boolean isNoValidateDoc()
- {
+ public boolean isNoValidateDoc() {
return novdoc;
}
/**
* Ignore extensions found in .xsdconfig files
- * @param novdoc
+ *
+ * @param noext Ignore extensions
*/
- public void setNoExt(boolean noext)
- {
+ public void setNoExt(boolean noext) {
this.noext = noext;
}
- public boolean isNoExt()
- {
+ public boolean isNoExt() {
return noext;
}
- /**
- * Generate java source compatible with the given version. Currently,
- * only "1.4" or "1.5" are supported and "1.4" is the default.
- */
- public void setJavaSource(String javasource)
- {
- this.javasource = javasource;
- }
+ //REVIEW this allows people to deal with the case where they drag in
+ //more files for compilation than they should. not sure if this is
+ //a good thing or not
+ private String source = null;
- public String getJavaSource()
- {
- return javasource;
+ public void setSource(String s) {
+ source = s;
}
- //REVIEW this allows people to deal with the case where they drag in
- //more files for compilation than they should. not sure if this is
- //a good thing or not
- private String source = null;
- public void setSource(String s) { source = s; }
-
/**
* Gets the XML Catalog file for org.apache.xml.resolver.tools.CatalogResolver. (Note: needs resolver.jar from http://xml.apache.org/commons/components/resolver/index.html)
*/
- public String getCatalog()
- {
+ public String getCatalog() {
return catalog;
}
/**
* Sets the XML Catalog file for org.apache.xml.resolver.tools.CatalogResolver. (Note: needs resolver.jar from http://xml.apache.org/commons/components/resolver/index.html)
*/
- public void setCatalog(String catalog)
- {
+ public void setCatalog(String catalog) {
this.catalog = catalog;
}
@@ -834,17 +764,14 @@ public class XMLBean extends MatchingTas
this.repackage = repackage;
}
- private static URI uriFromFile(File f)
- {
- if (f == null)
+ private static URI uriFromFile(File f) {
+ if (f == null) {
return null;
+ }
- try
- {
+ try {
return f.getCanonicalFile().toURI();
- }
- catch(java.io.IOException e)
- {
+ } catch (java.io.IOException e) {
// Don't spit out an exception here because on Windows you'll get one
// if the filename is "aux", "lpt1", etc. It's the caller's responsibility
// to deal with those cases correctly, usually by calling FileSvc.invalidPathCheck()
@@ -853,39 +780,31 @@ public class XMLBean extends MatchingTas
}
}
- public class ErrorLogger extends AbstractCollection
- {
- private boolean _noisy;
- private URI _baseURI;
+ public class ErrorLogger extends AbstractCollection<XmlError> {
+ private final boolean _noisy;
+ private final URI _baseURI;
- public ErrorLogger(boolean noisy)
- {
+ public ErrorLogger(boolean noisy) {
_noisy = noisy;
_baseURI = uriFromFile(project.getBaseDir());
}
- public boolean add(Object o)
- {
- if (o instanceof XmlError)
- {
- XmlError err = (XmlError)o;
- if (err.getSeverity() == XmlError.SEVERITY_ERROR)
- log(err.toString(_baseURI), Project.MSG_ERR);
- else if (err.getSeverity() == XmlError.SEVERITY_WARNING)
- log(err.toString(_baseURI), Project.MSG_WARN);
- else if (_noisy)
- log(err.toString(_baseURI), Project.MSG_INFO);
+ public boolean add(XmlError err) {
+ if (err.getSeverity() == XmlError.SEVERITY_ERROR) {
+ log(err.toString(_baseURI), Project.MSG_ERR);
+ } else if (err.getSeverity() == XmlError.SEVERITY_WARNING) {
+ log(err.toString(_baseURI), Project.MSG_WARN);
+ } else if (_noisy) {
+ log(err.toString(_baseURI), Project.MSG_INFO);
}
return false;
}
- public Iterator iterator()
- {
- return Collections.EMPTY_LIST.iterator();
+ public Iterator<XmlError> iterator() {
+ return Collections.emptyIterator();
}
- public int size()
- {
+ public int size() {
return 0;
}
}
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java?rev=1881778&r1=1881777&r2=1881778&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/values/XmlObjectBase.java Thu Sep 17 00:04:39 2020
@@ -20,7 +20,6 @@ import org.apache.xmlbeans.impl.common.*
import org.apache.xmlbeans.impl.schema.SchemaTypeImpl;
import org.apache.xmlbeans.impl.schema.SchemaTypeVisitorImpl;
import org.apache.xmlbeans.impl.validator.Validator;
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
@@ -130,25 +129,6 @@ public abstract class XmlObjectBase impl
}
}
- /**
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
- */
- public XMLInputStream newXMLInputStream() {
- return newXMLInputStream(null);
- }
-
- /**
- * @deprecated XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.
- */
- public XMLInputStream newXMLInputStream(XmlOptions options) {
- XmlCursor cur = newCursorForce();
- try {
- return cur.newXMLInputStream(makeInnerOptions(options));
- } finally {
- cur.dispose();
- }
- }
-
public XMLStreamReader newXMLStreamReader() {
return newXMLStreamReader(null);
}
@@ -3476,7 +3456,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementName);
boolean[] result = new boolean[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getBooleanValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getBooleanValue();
}
return result;
}
@@ -3487,7 +3467,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementName);
float[] result = new float[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getFloatValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getFloatValue();
}
return result;
}
@@ -3508,7 +3488,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementName);
byte[] result = new byte[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getByteValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getByteValue();
}
return result;
}
@@ -3519,7 +3499,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementName);
short[] result = new short[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getShortValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getShortValue();
}
return result;
}
@@ -3568,7 +3548,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementSet);
boolean[] result = new boolean[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getBooleanValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getBooleanValue();
}
return result;
}
@@ -3579,7 +3559,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementSet);
float[] result = new float[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getFloatValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getFloatValue();
}
return result;
}
@@ -3600,7 +3580,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementSet);
byte[] result = new byte[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getByteValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getByteValue();
}
return result;
}
@@ -3611,7 +3591,7 @@ public abstract class XmlObjectBase impl
List<XmlObjectBase> targetList = getBaseArray(elementSet);
short[] result = new short[targetList.size()];
for (int i = 0; i < result.length; i++) {
- result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getShortValue();
+ result[i] = ((org.apache.xmlbeans.SimpleValue) targetList.get(i)).getShortValue();
}
return result;
}
Modified: xmlbeans/trunk/src/test/java/random/common/Random.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/random/common/Random.java?rev=1881778&r1=1881777&r2=1881778&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/random/common/Random.java (original)
+++ xmlbeans/trunk/src/test/java/random/common/Random.java Thu Sep 17 00:04:39 2020
@@ -15,55 +15,52 @@
package random.common;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.SchemaType;
+import com.easypo.XmlCustomerBean;
+import com.easypo.XmlLineItemBean;
+import com.easypo.XmlPurchaseOrderDocumentBean.PurchaseOrder;
+import com.easypo.XmlShipperBean;
+import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.tool.CommandLine;
import org.apache.xmlbeans.impl.values.XmlValueDisconnectedException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Arrays;
import java.math.BigDecimal;
import java.math.BigInteger;
-import javax.xml.namespace.QName;
-
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
-
-import com.easypo.XmlPurchaseOrderDocumentBean.PurchaseOrder;
-import com.easypo.XmlCustomerBean;
-import com.easypo.XmlLineItemBean;
-import com.easypo.XmlShipperBean;
+import java.util.ArrayList;
+import java.util.Calendar;
public class Random implements Runnable {
- static long seed;
- static int iterations;
- static int threads;
- static int docs;
+ static long seed;
+ static int iterations;
+ static int threads;
+ static int docs;
public static void runTest(CommandLine cl) {
if (cl.getOpt("?") != null || cl.getOpt("help") != null ||
- cl.args().length != 0)
+ cl.args().length != 0) {
System.out.println(
- "Usage: random [-seed #] [-i iterations] [-t threads] [-docs docs] [-readonly] [-nosave]");
- else {
+ "Usage: random [-seed #] [-i iterations] [-t threads] [-docs docs] [-readonly] [-nosave]");
+ } else {
boolean readonly = false;
boolean nosave = false;
boolean noquery = false;
- if (cl.getOpt("seed") != null)
+ if (cl.getOpt("seed") != null) {
seed = Long.parseLong(cl.getOpt("seed"));
- if (cl.getOpt("i") != null)
+ }
+ if (cl.getOpt("i") != null) {
iterations = Integer.parseInt(cl.getOpt("i"));
- if (cl.getOpt("t") != null)
+ }
+ if (cl.getOpt("t") != null) {
threads = Integer.parseInt(cl.getOpt("t"));
- if (cl.getOpt("docs") != null)
+ }
+ if (cl.getOpt("docs") != null) {
docs = Integer.parseInt(cl.getOpt("docs"));
+ }
noquery = (cl.getOpt("noquery") != null);
readonly = (cl.getOpt("readonly") != null);
nosave = (cl.getOpt("nosave") != null);
@@ -90,7 +87,7 @@ public class Random implements Runnable
for (int i = 0; i < iterations; i++) {
for (int j = 0; j < threadCount; j++) {
Random runnable = new Random(seed, sharedDocs, readonly,
- nosave, noquery, threadCount > 1);
+ nosave, noquery, threadCount > 1);
threads[j] = new Thread(runnable);
threads[j].start();
seed++;
@@ -98,8 +95,7 @@ public class Random implements Runnable
for (int j = 0; j < threadCount; j++) {
try {
threads[j].join();
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
System.err.println("Thread interrupted");
}
}
@@ -109,15 +105,16 @@ public class Random implements Runnable
System.err.println();
System.err.println(
- "Seconds to run random tests: " + (end - start) / 1000);
+ "Seconds to run random tests: " + (end - start) / 1000);
}
public void run() {
System.err.print("\rSeed: " + _seed);
try {
- for (int d = 0; d < _docs.length; d++)
+ for (int d = 0; d < _docs.length; d++) {
_docs[d] = XmlObject.Factory.newInstance();
+ }
_cursors = new ArrayList();
@@ -129,8 +126,7 @@ public class Random implements Runnable
_iter++;
iterate();
good = true;
- }
- finally {
+ } finally {
if (!good) {
System.err.println();
System.err.println("Error on iteration " + _iter);
@@ -138,8 +134,7 @@ public class Random implements Runnable
}
}
}
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
System.err.println("Error on seed " + _seed);
e.printStackTrace(System.err);
}
@@ -199,16 +194,15 @@ public class Random implements Runnable
interateLow();
break;
}
- }
- catch (IllegalStateException e) {
- if (!_interference)
+ } catch (IllegalStateException e) {
+ if (!_interference) {
throw e;
- }
- catch (IllegalArgumentException e) {
- if (!_interference)
+ }
+ } catch (IllegalArgumentException e) {
+ if (!_interference) {
throw e;
- }
- catch (XmlValueDisconnectedException e) {
+ }
+ } catch (XmlValueDisconnectedException e) {
}
}
@@ -337,7 +331,7 @@ public class Random implements Runnable
execQuery();
break;
case 10:
- xmlInputStream();
+ xmlStreamReader();
break;
case 11:
docBytes();
@@ -364,31 +358,37 @@ public class Random implements Runnable
XmlCursor c = getCursor();
c.push();
- while (!(c.isContainer() || c.isAttr()))
- if (c.toNextToken().isNone())
+ while (!(c.isContainer() || c.isAttr())) {
+ if (c.toNextToken().isNone()) {
break;
+ }
+ }
if (!c.isEnddoc()) {
XmlObject x = c.getObject();
c.pop();
- if (x == null)
+ if (x == null) {
throw new IllegalStateException(
- "getObject returned null - content must have changed");
+ "getObject returned null - content must have changed");
+ }
return x;
}
c.pop();
c.push();
- while (!(c.isContainer() || c.isAttr()))
- if (c.toPrevToken().isNone())
+ while (!(c.isContainer() || c.isAttr())) {
+ if (c.toPrevToken().isNone()) {
break;
+ }
+ }
XmlObject x = c.getObject();
c.pop();
- if (x == null)
+ if (x == null) {
throw new IllegalStateException(
- "getObject returned null - content must have changed");
+ "getObject returned null - content must have changed");
+ }
return x;
}
@@ -413,11 +413,9 @@ public class Random implements Runnable
o = findObject();
SchemaType type = findObject().schemaType();
n = o.changeType(type);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
return;
- }
- catch (IllegalStateException e) {
+ } catch (IllegalStateException e) {
return;
}
@@ -440,38 +438,40 @@ public class Random implements Runnable
private void setName() {
XmlCursor c = findObject().newCursor();
- if (!c.isStartdoc())
+ if (!c.isStartdoc()) {
c.setName(getQName());
+ }
c.dispose();
}
private void newDomNode() {
- if (rnd(5) != 0)
+ if (rnd(5) != 0) {
return;
+ }
try {
getCursor().newDomNode();
- }
- catch (IllegalStateException e) {
+ } catch (IllegalStateException e) {
}
}
- private void xmlInputStream() throws Exception {
- if (rnd(5) != 0)
+ private void xmlStreamReader() throws Exception {
+ if (rnd(5) != 0) {
return;
+ }
- XMLInputStream xis;
+ XMLStreamReader xis;
try {
- xis = getCursor().newXMLInputStream();
- }
- catch (IllegalStateException e) {
+ xis = getCursor().newXMLStreamReader();
+ } catch (IllegalStateException e) {
return;
}
- while (xis.next() != null)
- ;
+ while (xis.hasNext()) {
+ xis.next();
+ }
}
private void objectSet() {
@@ -488,14 +488,17 @@ public class Random implements Runnable
XmlCustomerBean o = (XmlCustomerBean) x;
o.setName("Bob");
- if (rnd(2) == 0)
+ if (rnd(2) == 0) {
o.setAge(23);
+ }
- if (rnd(2) == 0)
+ if (rnd(2) == 0) {
o.setMoo(24);
+ }
- if (rnd(2) == 0)
+ if (rnd(2) == 0) {
o.setPoo(200);
+ }
} else if (x instanceof XmlLineItemBean) {
XmlLineItemBean o = (XmlLineItemBean) x;
o.setPerUnitOunces(new BigDecimal(122.44));
@@ -517,22 +520,25 @@ public class Random implements Runnable
}
private void execQuery() {
- if (_noquery)
+ if (_noquery) {
return;
+ }
- if (rnd(20) > 0)
+ if (rnd(20) > 0) {
return;
+ }
QName name = getQName();
String query =
- "declare namespace xxx='" + name.getNamespaceURI() + "' " +
- ".//xxx:" + name.getLocalPart();
+ "declare namespace xxx='" + name.getNamespaceURI() + "' " +
+ ".//xxx:" + name.getLocalPart();
XmlObject x = getCursor().execQuery(query).getObject();
- if (rnd(3) == 0)
+ if (rnd(3) == 0) {
_docs[rnd(_docs.length)] = x;
+ }
}
private void getObject() {
@@ -548,19 +554,18 @@ public class Random implements Runnable
getCursor().isInSameDocument(getCursor());
getCursor().comparePosition(getCursor());
getCursor().isAtSamePositionAs(getCursor());
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
}
}
private String[] _xmls =
- {
- "<a/>",
- };
+ {
+ "<a/>",
+ };
private String[] _schema_xmls =
- {
- "<po:purchase-order xmlns:po='http://openuri.org/easypo'>\n" +
+ {
+ "<po:purchase-order xmlns:po='http://openuri.org/easypo'>\n" +
"<po:customer age='31' poo='200'>\n" +
"<po:name>David Bau</po:name>\n" +
"<po:address>Gladwyne, PA</po:address>\n" +
@@ -594,20 +599,20 @@ public class Random implements Runnable
"</po:shipper>\n" +
"</po:purchase-order>\n" +
"",
- };
+ };
private void loadDoc() throws Exception {
if (rnd(15) == 0) {
_docs[rnd(_docs.length)] =
- XmlObject.Factory.parse(_xmls[rnd(_xmls.length)]);
+ XmlObject.Factory.parse(_xmls[rnd(_xmls.length)]);
}
}
private void loadSchemadDoc() throws Exception {
if (rnd(4) == 0) {
_docs[rnd(_docs.length)] =
- XmlObject.Factory.parse(
- _schema_xmls[rnd(_schema_xmls.length)]);
+ XmlObject.Factory.parse(
+ _schema_xmls[rnd(_schema_xmls.length)]);
}
}
@@ -620,18 +625,19 @@ public class Random implements Runnable
}
private char[] _chars =
- {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- ' ', '<', '>', '&', '-', '?'
- };
+ {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ ' ', '<', '>', '&', '-', '?'
+ };
private void getTextValue() {
XmlCursor c = getCursor();
- if (c.isFinish() || c.isNamespace() || c.isText())
+ if (c.isFinish() || c.isNamespace() || c.isText()) {
return;
+ }
c.getTextValue();
}
@@ -639,13 +645,15 @@ public class Random implements Runnable
private void setTextValue() {
XmlCursor c = getCursor();
- if (c.isFinish() || c.isNamespace() || c.isText())
+ if (c.isFinish() || c.isNamespace() || c.isText()) {
return;
+ }
StringBuilder sb = new StringBuilder();
- for (int i = rnd(10); i >= 0; i--)
+ for (int i = rnd(10); i >= 0; i--) {
sb.append(_chars[rnd(_chars.length)]);
+ }
c.setTextValue(sb.toString());
}
@@ -653,20 +661,16 @@ public class Random implements Runnable
private void moveText() {
try {
getCursor().moveChars(rnd(10), getCursor());
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
private void copyText() {
try {
getCursor().copyChars(rnd(10), getCursor());
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
@@ -677,33 +681,31 @@ public class Random implements Runnable
private void insertComment() {
try {
getCursor().insertComment("poo");
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
private void insertProcinst() {
try {
getCursor().insertProcInst("target", "val");
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
private void insertText() {
XmlCursor c = getCursor();
- if (c.isAnyAttr() || c.isStartdoc())
+ if (c.isAnyAttr() || c.isStartdoc()) {
return;
+ }
StringBuilder sb = new StringBuilder();
- for (int i = rnd(10); i >= 0; i--)
+ for (int i = rnd(10); i >= 0; i--) {
sb.append(_chars[rnd(_chars.length)]);
+ }
c.insertChars(sb.toString());
}
@@ -753,8 +755,9 @@ public class Random implements Runnable
private void insertElem() throws Exception {
XmlCursor c = getCursor();
- if (c.isAnyAttr() || c.isStartdoc())
+ if (c.isAnyAttr() || c.isStartdoc()) {
return;
+ }
c.insertElement(getQName());
}
@@ -762,11 +765,13 @@ public class Random implements Runnable
public void insertAttr() {
XmlCursor c = getCursor();
- while (!c.isEnddoc() && !c.isContainer())
+ while (!c.isEnddoc() && !c.isContainer()) {
c.toNextToken();
+ }
- if (c.isEnddoc())
+ if (c.isEnddoc()) {
return;
+ }
c.toNextToken();
@@ -782,48 +787,41 @@ public class Random implements Runnable
public void copyXmlContents() {
try {
getCursor().copyXmlContents(getCursor());
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
public void copyXml() {
try {
getCursor().copyXml(getCursor());
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
public void moveXmlContents() {
try {
getCursor().moveXmlContents(getCursor());
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
public void moveXml() {
try {
getCursor().moveXml(getCursor());
- }
- catch (IllegalArgumentException e) {
- }
- catch (IllegalStateException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalStateException e) {
}
}
public void removeXml() {
XmlCursor c = getCursor();
- if (!c.isStartdoc() && !c.isFinish())
+ if (!c.isStartdoc() && !c.isFinish()) {
c.removeXml();
+ }
}
public static class Bookmark extends XmlCursor.XmlBookmark {
Modified: xmlbeans/trunk/src/test/java/xmlobject/detailed/SoapFaultTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmlobject/detailed/SoapFaultTest.java?rev=1881778&r1=1881777&r2=1881778&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmlobject/detailed/SoapFaultTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmlobject/detailed/SoapFaultTest.java Thu Sep 17 00:04:39 2020
@@ -15,6 +15,7 @@
package xmlobject.detailed;
+import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.junit.Ignore;
@@ -39,7 +40,7 @@ public class SoapFaultTest {
@Ignore
public void testSetDetail() throws Exception {
Fault fault = Fault.Factory.newInstance();
- fault.setDetail(Detail.Factory.parse(XmlObject.Factory.parse("<foo/>").newXMLInputStream()));
+ fault.setDetail(Detail.Factory.parse(XmlObject.Factory.parse("<foo/>").newXMLStreamReader()));
assertEquals("<detail><foo/></detail>", fault.xmlText());
assertEquals("<xml-fragment><foo/></xml-fragment>", fault.getDetail().xmlText());
@@ -58,10 +59,10 @@ public class SoapFaultTest {
XmlObject.Factory.parse("<foo/>").changeType(Detail.type));
String expect = "<xml-fragment>" +
- "<faultcode xmlns:soapenv=\"" + soapenv + "\">soapenv:foo</faultcode>" +
- "<faultstring>Undefined</faultstring>" +
- "<detail><foo/></detail>" +
- "</xml-fragment>";
+ "<faultcode xmlns:soapenv=\"" + soapenv + "\">soapenv:foo</faultcode>" +
+ "<faultstring>Undefined</faultstring>" +
+ "<detail><foo/></detail>" +
+ "</xml-fragment>";
assertEquals(expect, fault.xmlText());
assertEquals(new QName(soapenv, "foo"), fault.getFaultcode());
assertEquals("Undefined", fault.getFaultstring());
@@ -93,7 +94,7 @@ public class SoapFaultTest {
Fault faultDoc = Fault.Factory.parse(soapFault);
XmlOptions opt = new XmlOptions();
- ArrayList errors = new ArrayList();
+ ArrayList<XmlError> errors = new ArrayList<>();
opt.setErrorListener(errors);
assertTrue(faultDoc.validate(opt));
assertEquals(new QName(soapenv, "Server"), faultDoc.getFaultcode());
Modified: xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java?rev=1881778&r1=1881777&r2=1881778&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java (original)
+++ xmlbeans/trunk/src/test/java/xmltokensource/detailed/RoundTripLoaderTest.java Thu Sep 17 00:04:39 2020
@@ -19,7 +19,6 @@ package xmltokensource.detailed;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.xml.stream.XMLInputStream;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Node;
@@ -106,44 +105,6 @@ public class RoundTripLoaderTest extends
}
}
- /**
- * yana_kadiyska (3:25:15 PM): Eric, is this going to be impl
- * on this release? Bug? store.Cursor._newXMLInputStream
- * ericvasilik (3:26:01 PM): This is not a v2 feature. ...
- * but otherwise, we should disable XMLInputStream tests
- * <p>
- * public void testNewReaderRoundTrip() throws Exception {
- * _newReaderRoundTrip(null);
- * }
- * <p>
- * public void testNewReaderWithOptionsRoundTrip() throws Exception {
- * _newReaderRoundTrip(m_map);
- * }
- */
-
- private void _newXMLInputStreamRoundTrip(XmlOptions map) throws Exception {
- m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
- XMLInputStream xmlIs = m_xo.newXMLInputStream(map);
- assertNotNull(xmlIs);
- XmlObject xo = XmlObject.Factory.parse(xmlIs, map);
- m_xc = m_xo.newCursor();
- XmlCursor xc1 = xo.newCursor();
- try {
- compareDocTokens(m_xc, xc1);
- } finally {
- xc1.dispose();
- }
- }
-
- @Test
- public void testNewXMLInputStreamRoundTrip() throws Exception {
- _newXMLInputStreamRoundTrip(null);
- }
-
- public void testNewXMLInputStreamWithOptionsRoundTrip() throws Exception {
- _newXMLInputStreamRoundTrip(m_map);
- }
-
private void _xmlTextRoundTrip(XmlOptions map) throws Exception {
m_xo = XmlObject.Factory.parse(Common.XML_FOO_BAR_NESTED_SIBLINGS);
String sXml = m_xo.xmlText(map);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org