Package org.apache.xmlbeans.impl.tool

Examples of org.apache.xmlbeans.impl.tool.CommandLine


    opts.add("schemaCodePrinter");
    opts.add("extension");
    opts.add("extensionParms");
    opts.add("allowmdef");
    opts.add("catalog");
    CommandLine cl = new CommandLine(args, flags, opts);


    String[] badopts = cl.getBadOpts();
    if (badopts.length > 0) {
      for (int i = 0; i < badopts.length; i++)
        System.out.println("Unrecognized option: " + badopts[i]);
      return;
    }

    args = cl.args();
    boolean verbose = (cl.getOpt("verbose") != null);
    boolean quiet = (cl.getOpt("quiet") != null);
    if (verbose)
      quiet = false;


    String outputfilename = cl.getOpt("out");

    String repackage = cl.getOpt("repackage");

    String codePrinterClass = cl.getOpt("schemaCodePrinter");
    SchemaCodePrinter codePrinter = null;
    String name = cl.getOpt("name");

    boolean download = (cl.getOpt("dl") != null);
    boolean noUpa = (cl.getOpt("noupa") != null);
    boolean noPvr = (cl.getOpt("nopvr") != null);
    boolean noAnn = (cl.getOpt("noann") != null);
    boolean noVDoc = (cl.getOpt("novdoc") != null);
    boolean noExt = (cl.getOpt("noext") != null);
    boolean nojavac = (cl.getOpt("srconly") != null);
    boolean debug = (cl.getOpt("debug") != null);

    String allowmdef = cl.getOpt("allowmdef");
    Set mdefNamespaces = (allowmdef == null ? Collections.EMPTY_SET
        : new HashSet(Arrays.asList(XmlListImpl.split_list(allowmdef))));

    List extensions = new ArrayList();

    String classesdir = cl.getOpt("d");
    File classes = null;
    if (classesdir != null)
      classes = new File(classesdir);

    String srcdir = cl.getOpt("src");
    File src = null;
    if (srcdir != null)
      src = new File(srcdir);
    if (nojavac && srcdir == null && classes != null)
      src = classes;

    // create temp directory
    File tempdir = null;
    if (src == null || classes == null) {
      throw new XBayaRuntimeException("Code gen src directory or classes directory is null");
    }

    File jarfile = null;
    if (outputfilename == null && classes == null && !nojavac)
      outputfilename = "xmltypes.jar";
    if (outputfilename != null)
      jarfile = new File(outputfilename);

    if (src == null)
      src = IOUtil.createDir(tempdir, "src");
    if (classes == null)
      classes = IOUtil.createDir(tempdir, "classes");

    File[] classpath = null;
    String cpString = cl.getOpt("cp");
    if (cpString != null) {
      String[] cpparts = cpString.split(File.pathSeparator);
      List cpList = new ArrayList();
      for (int i = 0; i < cpparts.length; i++)
        cpList.add(new File(cpparts[i]));
      classpath = (File[]) cpList.toArray(new File[cpList.size()]);
    } else {
      classpath = CodeGenUtil.systemClasspath();
    }

    String javasource = cl.getOpt("javasource");
    String compiler = cl.getOpt("compiler");
    String jar = cl.getOpt("jar");
    if (verbose && jar != null)
      System.out.println("The 'jar' option is no longer supported.");

    String memoryInitialSize = cl.getOpt("ms");
    String memoryMaximumSize = cl.getOpt("mx");

    File[] xsdFiles = cl.filesEndingWith(".xsd");
    File[] wsdlFiles = cl.filesEndingWith(".wsdl");
    File[] javaFiles = cl.filesEndingWith(".java");
    File[] configFiles = cl.filesEndingWith(".xsdconfig");
    URL[] urlFiles = cl.getURLs();

    if (xsdFiles.length + wsdlFiles.length + urlFiles.length == 0) {
      System.out
          .println("Could not find any xsd or wsdl files to process.");
      return;
    }
    File baseDir = cl.getBaseDir();
    URI baseURI = baseDir == null ? null : baseDir.toURI();

    XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);

    String catString = cl.getOpt("catalog");

    Parameters params = new Parameters();
    params.setBaseDir(baseDir);
    params.setXsdFiles(xsdFiles);
    params.setWsdlFiles(wsdlFiles);
View Full Code Here


        opts.add("schemaCodePrinter");
        opts.add("extension");
        opts.add("extensionParms");
        opts.add("allowmdef");
        opts.add("catalog");
        CommandLine cl = new CommandLine(args, flags, opts);

        String[] badopts = cl.getBadOpts();
        if (badopts.length > 0) {
            for (int i = 0; i < badopts.length; i++)
                System.out.println("Unrecognized option: " + badopts[i]);
            return;
        }

        boolean verbose = (cl.getOpt("verbose") != null);
        boolean quiet = (cl.getOpt("quiet") != null);
        if (verbose)
            quiet = false;

        String outputfilename = cl.getOpt("out");

        String repackage = cl.getOpt("repackage");

        cl.getOpt("schemaCodePrinter");
        SchemaCodePrinter codePrinter = null;
        String name = cl.getOpt("name");

        boolean download = (cl.getOpt("dl") != null);
        boolean noUpa = (cl.getOpt("noupa") != null);
        boolean noPvr = (cl.getOpt("nopvr") != null);
        boolean noAnn = (cl.getOpt("noann") != null);
        boolean noVDoc = (cl.getOpt("novdoc") != null);
        boolean noExt = (cl.getOpt("noext") != null);
        boolean nojavac = (cl.getOpt("srconly") != null);
        boolean debug = (cl.getOpt("debug") != null);

        String allowmdef = cl.getOpt("allowmdef");
        Set mdefNamespaces = (allowmdef == null ? Collections.EMPTY_SET : new HashSet(Arrays.asList(XmlListImpl
                .split_list(allowmdef))));

        List extensions = new ArrayList();

        String classesdir = cl.getOpt("d");
        File classes = null;
        if (classesdir != null)
            classes = new File(classesdir);

        String srcdir = cl.getOpt("src");
        File src = null;
        if (srcdir != null)
            src = new File(srcdir);
        if (nojavac && srcdir == null && classes != null)
            src = classes;

        // create temp directory
        File tempdir = null;
        if (src == null || classes == null) {
            throw new WorkflowRuntimeException("Code gen src directory or classes directory is null");
        }

        File jarfile = null;
        if (outputfilename == null && classes == null && !nojavac)
            outputfilename = "xmltypes.jar";
        if (outputfilename != null)
            jarfile = new File(outputfilename);

        if (src == null)
            src = IOUtil.createDir(tempdir, "src");
        if (classes == null)
            classes = IOUtil.createDir(tempdir, "classes");

        File[] classpath = null;
        String cpString = cl.getOpt("cp");
        if (cpString != null) {
            String[] cpparts = cpString.split(File.pathSeparator);
            List cpList = new ArrayList();
            for (int i = 0; i < cpparts.length; i++)
                cpList.add(new File(cpparts[i]));
            classpath = (File[]) cpList.toArray(new File[cpList.size()]);
        } else {
            classpath = CodeGenUtil.systemClasspath();
        }

        String javasource = cl.getOpt("javasource");
        String compiler = cl.getOpt("compiler");
        String jar = cl.getOpt("jar");
        if (verbose && jar != null)
            System.out.println("The 'jar' option is no longer supported.");

        String memoryInitialSize = cl.getOpt("ms");
        String memoryMaximumSize = cl.getOpt("mx");

        File[] xsdFiles = cl.filesEndingWith(".xsd");
        File[] wsdlFiles = cl.filesEndingWith(".wsdl");
        File[] javaFiles = cl.filesEndingWith(".java");
        File[] configFiles = cl.filesEndingWith(".xsdconfig");
        URL[] urlFiles = cl.getURLs();

        if (xsdFiles.length + wsdlFiles.length + urlFiles.length == 0) {
            System.out.println("Could not find any xsd or wsdl files to process.");
            return;
        }
        File baseDir = cl.getBaseDir();
        URI baseURI = baseDir == null ? null : baseDir.toURI();

        XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);

        String catString = cl.getOpt("catalog");

        Parameters params = new Parameters();
        params.setBaseDir(baseDir);
        params.setXsdFiles(xsdFiles);
        params.setWsdlFiles(wsdlFiles);
View Full Code Here

        flags.add("noupa");
        flags.add("nopvr");
        flags.add("partial");
        opts.add("name");

        CommandLine cl = new CommandLine(args, flags, opts);
        if (cl.getOpt("h") != null || cl.getOpt("help") != null || cl.getOpt("usage") != null)
        {
            printUsage();
            return;
        }

        String[] badOpts = cl.getBadOpts();
        if (badOpts.length > 0)
        {
            for (int i = 0; i < badOpts.length; i++)
                System.out.println("Unrecognized option: " + badOpts[i]);
            printUsage();
            return;
        }

        if (cl.getOpt("license") != null)
        {
            CommandLine.printLicense();
            System.exit(0);
            return;
        }

        if (cl.getOpt("version") != null)
        {
            CommandLine.printVersion();
            System.exit(0);
            return;
        }

        boolean dl = (cl.getOpt("dl") != null);
        boolean nopvr = (cl.getOpt("nopvr") != null);
        boolean noupa = (cl.getOpt("noupa") != null);

        File[] schemaFiles = cl.filesEndingWith(".xsd");
        String rootName = cl.getOpt("name");

        if (rootName == null)
        {
            System.out.println("Required option \"-name\" must be present");
            return;
View Full Code Here

        opts.add("simple-content-types");
        opts.add("enumerations");
        opts.add("outDir");
        opts.add("outPrefix");

        CommandLine cl = new CommandLine(args, flags, opts);
        Inst2XsdOptions inst2XsdOptions = new Inst2XsdOptions();

        if (cl.getOpt("license") != null)
        {
            CommandLine.printLicense();
            System.exit(0);
            return;
        }

        if (cl.getOpt("version") != null)
        {
            CommandLine.printVersion();
            System.exit(0);
            return;
        }

        if (cl.getOpt("h") != null || cl.getOpt("help") != null || cl.getOpt("usage") != null)
        {
            printHelp();
            System.exit(0);
            return;
        }

        String[] badopts = cl.getBadOpts();
        if (badopts.length > 0)
        {
            for (int i = 0; i < badopts.length; i++)
                System.out.println("Unrecognized option: " + badopts[i]);
            printHelp();
            System.exit(0);
            return;
        }

        String design = cl.getOpt("design");
        if (design==null)
        {
            // default
        }
        else if (design.equals("vb"))
        {
            inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_VENETIAN_BLIND);
        }
        else if (design.equals("rd"))
        {
            inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_RUSSIAN_DOLL);
        }
        else if (design.equals("ss"))
        {
            inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_SALAMI_SLICE);
        }
        else
        {
            printHelp();
            System.exit(0);
            return;
        }

        String simpleContent = cl.getOpt("simple-content-types");
        if (simpleContent==null)
        {
            //default
        }
        else if (simpleContent.equals("smart"))
        {
            inst2XsdOptions.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
        }
        else if (simpleContent.equals("string"))
        {
            inst2XsdOptions.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
        }
        else
        {
            printHelp();
            System.exit(0);
            return;
        }

        String enumerations = cl.getOpt("enumerations");
        if (enumerations==null)
        {
            // default
        }
        else if (enumerations.equals("never"))
        {
            inst2XsdOptions.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
        }
        else
        {
            try
            {
                int intVal = Integer.parseInt(enumerations);
                inst2XsdOptions.setUseEnumerations(intVal);
            }
            catch (NumberFormatException e)
            {
                printHelp();
                System.exit(0);
                return;
            }
        }

        File outDir = new File( cl.getOpt("outDir")==null ? "." : cl.getOpt("outDir"));

        String outPrefix = cl.getOpt("outPrefix");
        if (outPrefix==null)
            outPrefix = "schema";

        inst2XsdOptions.setVerbose((cl.getOpt("verbose") != null));
        boolean validate = cl.getOpt("validate")!=null;

        File[] xmlFiles = cl.filesEndingWith(".xml");
        XmlObject[] xmlInstances = new XmlObject[xmlFiles.length];

        if ( xmlInstances.length==0 )
        {
            printHelp();
View Full Code Here

        flags.add("noupa");
        flags.add("nopvr");
        flags.add("partial");
        opts.add("name");

        CommandLine cl = new CommandLine(args, flags, opts);
        if (cl.getOpt("h") != null || cl.getOpt("help") != null || cl.getOpt("usage") != null)
        {
            printUsage();
            return;
        }

        String[] badOpts = cl.getBadOpts();
        if (badOpts.length > 0)
        {
            for (int i = 0; i < badOpts.length; i++)
                System.out.println("Unrecognized option: " + badOpts[i]);
            printUsage();
            return;
        }

        if (cl.getOpt("license") != null)
        {
            CommandLine.printLicense();
            System.exit(0);
            return;
        }

        if (cl.getOpt("version") != null)
        {
            CommandLine.printVersion();
            System.exit(0);
            return;
        }

        boolean dl = (cl.getOpt("dl") != null);
        boolean nopvr = (cl.getOpt("nopvr") != null);
        boolean noupa = (cl.getOpt("noupa") != null);

        File[] schemaFiles = cl.filesEndingWith(".xsd");
        String rootName = cl.getOpt("name");

        if (rootName == null)
        {
            System.out.println("Required option \"-name\" must be present");
            return;
View Full Code Here

        opts.add("schemaCodePrinter");
        opts.add("extension");
        opts.add("extensionParms");
        opts.add("allowmdef");
        opts.add("catalog");
        CommandLine cl = new CommandLine(args, flags, opts);

        String[] badopts = cl.getBadOpts();
        if (badopts.length > 0) {
            for (int i = 0; i < badopts.length; i++)
                System.out.println("Unrecognized option: " + badopts[i]);
            return;
        }

        boolean verbose = (cl.getOpt("verbose") != null);
        boolean quiet = (cl.getOpt("quiet") != null);
        if (verbose)
            quiet = false;

        String outputfilename = cl.getOpt("out");

        String repackage = cl.getOpt("repackage");

        cl.getOpt("schemaCodePrinter");
        SchemaCodePrinter codePrinter = null;
        String name = cl.getOpt("name");

        boolean download = (cl.getOpt("dl") != null);
        boolean noUpa = (cl.getOpt("noupa") != null);
        boolean noPvr = (cl.getOpt("nopvr") != null);
        boolean noAnn = (cl.getOpt("noann") != null);
        boolean noVDoc = (cl.getOpt("novdoc") != null);
        boolean noExt = (cl.getOpt("noext") != null);
        boolean nojavac = (cl.getOpt("srconly") != null);
        boolean debug = (cl.getOpt("debug") != null);

        String allowmdef = cl.getOpt("allowmdef");
        Set mdefNamespaces = (allowmdef == null ? Collections.EMPTY_SET : new HashSet(Arrays.asList(XmlListImpl
                .split_list(allowmdef))));

        List extensions = new ArrayList();

        String classesdir = cl.getOpt("d");
        File classes = null;
        if (classesdir != null)
            classes = new File(classesdir);

        String srcdir = cl.getOpt("src");
        File src = null;
        if (srcdir != null)
            src = new File(srcdir);
        if (nojavac && srcdir == null && classes != null)
            src = classes;

        // create temp directory
        File tempdir = null;
        if (src == null || classes == null) {
            throw new XBayaRuntimeException("Code gen src directory or classes directory is null");
        }

        File jarfile = null;
        if (outputfilename == null && classes == null && !nojavac)
            outputfilename = "xmltypes.jar";
        if (outputfilename != null)
            jarfile = new File(outputfilename);

        if (src == null)
            src = IOUtil.createDir(tempdir, "src");
        if (classes == null)
            classes = IOUtil.createDir(tempdir, "classes");

        File[] classpath = null;
        String cpString = cl.getOpt("cp");
        if (cpString != null) {
            String[] cpparts = cpString.split(File.pathSeparator);
            List cpList = new ArrayList();
            for (int i = 0; i < cpparts.length; i++)
                cpList.add(new File(cpparts[i]));
            classpath = (File[]) cpList.toArray(new File[cpList.size()]);
        } else {
            classpath = CodeGenUtil.systemClasspath();
        }

        String javasource = cl.getOpt("javasource");
        String compiler = cl.getOpt("compiler");
        String jar = cl.getOpt("jar");
        if (verbose && jar != null)
            System.out.println("The 'jar' option is no longer supported.");

        String memoryInitialSize = cl.getOpt("ms");
        String memoryMaximumSize = cl.getOpt("mx");

        File[] xsdFiles = cl.filesEndingWith(".xsd");
        File[] wsdlFiles = cl.filesEndingWith(".wsdl");
        File[] javaFiles = cl.filesEndingWith(".java");
        File[] configFiles = cl.filesEndingWith(".xsdconfig");
        URL[] urlFiles = cl.getURLs();

        if (xsdFiles.length + wsdlFiles.length + urlFiles.length == 0) {
            System.out.println("Could not find any xsd or wsdl files to process.");
            return;
        }
        File baseDir = cl.getBaseDir();
        URI baseURI = baseDir == null ? null : baseDir.toURI();

        XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);

        String catString = cl.getOpt("catalog");

        Parameters params = new Parameters();
        params.setBaseDir(baseDir);
        params.setXsdFiles(xsdFiles);
        params.setWsdlFiles(wsdlFiles);
View Full Code Here

public class Random implements Runnable
{
    public static void main ( String[] args ) throws Exception
    {
        CommandLine cl = new CommandLine(args, Arrays.asList(new String[] { "seed", "i", "t", "docs", "?", "help" }));
        long seed = System.currentTimeMillis();
        int iterations = Integer.MAX_VALUE;
        int threads = 1;
        int docs = 10;
       
        if (cl.getOpt("?") != null || cl.getOpt("help") != null || cl.args().length != 0)
            System.out.println("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)
                seed = Long.parseLong(cl.getOpt("seed"));
            if (cl.getOpt("i") != null)
                iterations = Integer.parseInt(cl.getOpt("i"));
            if (cl.getOpt("t") != null)
                threads = Integer.parseInt(cl.getOpt("t"));
            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);
               
            System.out.println("seed=" + seed);
            System.out.println("iterations=" + iterations );
            System.out.println("threads=" + threads);
            System.out.println("docs=" + docs );
View Full Code Here

public class Random implements Runnable
{
    public static void main ( String[] args ) throws Exception
    {
        CommandLine cl = new CommandLine(args, Arrays.asList(new String[] { "seed", "i", "t", "docs", "?", "help" }));
        long seed = System.currentTimeMillis();
        int iterations = Integer.MAX_VALUE;
        int threads = 1;
        int docs = 10;
       
        if (cl.getOpt("?") != null || cl.getOpt("help") != null || cl.args().length != 0)
            System.out.println("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)
                seed = Long.parseLong(cl.getOpt("seed"));
            if (cl.getOpt("i") != null)
                iterations = Integer.parseInt(cl.getOpt("i"));
            if (cl.getOpt("t") != null)
                threads = Integer.parseInt(cl.getOpt("t"));
            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);
               
            System.out.println("seed=" + seed);
            System.out.println("iterations=" + iterations );
            System.out.println("threads=" + threads);
            System.out.println("docs=" + docs );
View Full Code Here

        opts.add("simple-content-types");
        opts.add("enumerations");
        opts.add("outDir");
        opts.add("outPrefix");

        CommandLine cl = new CommandLine(args, flags, opts);
        Inst2XsdOptions inst2XsdOptions = new Inst2XsdOptions();

        if (cl.getOpt("license") != null)
        {
            CommandLine.printLicense();
            System.exit(0);
            return;
        }

        if (cl.getOpt("version") != null)
        {
            CommandLine.printVersion();
            System.exit(0);
            return;
        }

        if (cl.getOpt("h") != null || cl.getOpt("help") != null || cl.getOpt("usage") != null)
        {
            printHelp();
            System.exit(0);
            return;
        }

        String[] badopts = cl.getBadOpts();
        if (badopts.length > 0)
        {
            for (int i = 0; i < badopts.length; i++)
                System.out.println("Unrecognized option: " + badopts[i]);
            printHelp();
            System.exit(0);
            return;
        }

        String design = cl.getOpt("design");
        if (design==null)
        {
            // default
        }
        else if (design.equals("vb"))
        {
            inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_VENETIAN_BLIND);
        }
        else if (design.equals("rd"))
        {
            inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_RUSSIAN_DOLL);
        }
        else if (design.equals("ss"))
        {
            inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_SALAMI_SLICE);
        }
        else
        {
            printHelp();
            System.exit(0);
            return;
        }

        String simpleContent = cl.getOpt("simple-content-types");
        if (simpleContent==null)
        {
            //default
        }
        else if (simpleContent.equals("smart"))
        {
            inst2XsdOptions.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_SMART);
        }
        else if (simpleContent.equals("string"))
        {
            inst2XsdOptions.setSimpleContentTypes(Inst2XsdOptions.SIMPLE_CONTENT_TYPES_STRING);
        }
        else
        {
            printHelp();
            System.exit(0);
            return;
        }

        String enumerations = cl.getOpt("enumerations");
        if (enumerations==null)
        {
            // default
        }
        else if (enumerations.equals("never"))
        {
            inst2XsdOptions.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER);
        }
        else
        {
            try
            {
                int intVal = Integer.parseInt(enumerations);
                inst2XsdOptions.setUseEnumerations(intVal);
            }
            catch (NumberFormatException e)
            {
                printHelp();
                System.exit(0);
                return;
            }
        }

        File outDir = new File( cl.getOpt("outDir")==null ? "." : cl.getOpt("outDir"));

        String outPrefix = cl.getOpt("outPrefix");
        if (outPrefix==null)
            outPrefix = "schema";

        inst2XsdOptions.setVerbose((cl.getOpt("verbose") != null));
        boolean validate = cl.getOpt("validate")!=null;

        File[] xmlFiles = cl.filesEndingWith(".xml");
        XmlObject[] xmlInstances = new XmlObject[xmlFiles.length];

        if ( xmlInstances.length==0 )
        {
            printHelp();
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.impl.tool.CommandLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.