Java源码示例:com.sun.tools.internal.xjc.Options

示例1
public boolean run(
    Outline outline,
    Options opt,
    ErrorHandler errorHandler ) {

    for( ClassOutline ci : outline.getClasses() ) {
        JDefinedClass impl = ci.implClass;
        if (ci.getSuperClass() == null) {
            JVar $loc = impl.field(JMod.PROTECTED, Locator.class, fieldName);
            $loc.annotate(XmlLocation.class);
            $loc.annotate(XmlTransient.class);

            impl._implements(Locatable.class);

            impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc);

            JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation");
            JVar $newLoc = setter.param(Locator.class, "newLocator");
            setter.body().assign($loc, $newLoc);
        }
    }

    return true;
}
 
示例2
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
示例3
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
    for( ClassOutline co : model.getClasses() ) {
        CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code");
        if(c==null)
            continue;   // no customization --- nothing to inject here

        c.markAsAcknowledged();
        // TODO: ideally you should validate this DOM element to make sure
        // that there's no typo/etc. JAXP 1.3 can do this very easily.
        String codeFragment = DOMUtils.getElementText(c.element);

        // inject the specified code fragment into the implementation class.
        co.implClass.direct(codeFragment);
    }

    return true;
}
 
示例4
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
示例5
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
示例6
/**
 * @param nc
 *      Usually this should be set in the constructor, but we do allow this parameter
 *      to be initially null, and then set later.
 * @param schemaComponent
 *      The source schema model, if this is built from XSD.
 */
public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) {
    this.options = opts;
    this.codeModel = cm;
    this.nameConverter = nc;
    this.defaultSymbolSpace = new SymbolSpace(codeModel);
    defaultSymbolSpace.setType(codeModel.ref(Object.class));

    elementMappings.put(null,new HashMap<QName,CElementInfo>());

    if(opts.automaticNameConflictResolution)
        allocator = new AutoClassNameAllocator(allocator);
    this.allocator = new ClassNameAllocatorWrapper(allocator);
    this.schemaComponent = schemaComponent;
    this.gloablCustomizations.setParent(this,this);
}
 
示例7
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
    for( ClassOutline co : model.getClasses() ) {
        CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code");
        if(c==null)
            continue;   // no customization --- nothing to inject here

        c.markAsAcknowledged();
        // TODO: ideally you should validate this DOM element to make sure
        // that there's no typo/etc. JAXP 1.3 can do this very easily.
        String codeFragment = DOMUtils.getElementText(c.element);

        // inject the specified code fragment into the implementation class.
        co.implClass.direct(codeFragment);
    }

    return true;
}
 
示例8
/**
 * Parses an XML at the given location (
 * and XMLs referenced by it) into DOM trees
 * and stores them to this forest.
 *
 * @return the parsed DOM document object.
 */
public Document parse( String systemId, boolean root ) throws SAXException, IOException {

    systemId = Options.normalizeSystemId(systemId);

    if( core.containsKey(systemId) )
        // this document has already been parsed. Just ignore.
        return core.get(systemId);

    InputSource is=null;

    // allow entity resolver to find the actual byte stream.
    if( entityResolver!=null )
        is = entityResolver.resolveEntity(null,systemId);
    if( is==null )
        is = new InputSource(systemId);

    // but we still use the original system Id as the key.
    return parse( systemId, is, root );
}
 
示例9
public boolean run(
    Outline outline,
    Options opt,
    ErrorHandler errorHandler ) {

    for( ClassOutline ci : outline.getClasses() ) {
        JDefinedClass impl = ci.implClass;
        if (ci.getSuperClass() == null) {
            JVar $loc = impl.field(JMod.PROTECTED, Locator.class, fieldName);
            $loc.annotate(XmlLocation.class);
            $loc.annotate(XmlTransient.class);

            impl._implements(Locatable.class);

            impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc);

            JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation");
            JVar $newLoc = setter.param(Locator.class, "newLocator");
            setter.body().assign($loc, $newLoc);
        }
    }

    return true;
}
 
示例10
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
示例11
/**
 * Parses an XML at the given location (
 * and XMLs referenced by it) into DOM trees
 * and stores them to this forest.
 *
 * @return the parsed DOM document object.
 */
public Document parse( String systemId, boolean root ) throws SAXException, IOException {

    systemId = Options.normalizeSystemId(systemId);

    if( core.containsKey(systemId) )
        // this document has already been parsed. Just ignore.
        return core.get(systemId);

    InputSource is=null;

    // allow entity resolver to find the actual byte stream.
    if( entityResolver!=null )
        is = entityResolver.resolveEntity(null,systemId);
    if( is==null )
        is = new InputSource(systemId);

    // but we still use the original system Id as the key.
    return parse( systemId, is, root );
}
 
示例12
/**
 * @param nc
 *      Usually this should be set in the constructor, but we do allow this parameter
 *      to be initially null, and then set later.
 * @param schemaComponent
 *      The source schema model, if this is built from XSD.
 */
public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) {
    this.options = opts;
    this.codeModel = cm;
    this.nameConverter = nc;
    this.defaultSymbolSpace = new SymbolSpace(codeModel);
    defaultSymbolSpace.setType(codeModel.ref(Object.class));

    elementMappings.put(null,new HashMap<QName,CElementInfo>());

    if(opts.automaticNameConflictResolution)
        allocator = new AutoClassNameAllocator(allocator);
    this.allocator = new ClassNameAllocatorWrapper(allocator);
    this.schemaComponent = schemaComponent;
    this.gloablCustomizations.setParent(this,this);
}
 
示例13
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
示例14
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
    for( ClassOutline co : model.getClasses() ) {
        CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code");
        if(c==null)
            continue;   // no customization --- nothing to inject here

        c.markAsAcknowledged();
        // TODO: ideally you should validate this DOM element to make sure
        // that there's no typo/etc. JAXP 1.3 can do this very easily.
        String codeFragment = DOMUtils.getElementText(c.element);

        // inject the specified code fragment into the implementation class.
        co.implClass.direct(codeFragment);
    }

    return true;
}
 
示例15
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
    for( ClassOutline co : model.getClasses() ) {
        CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code");
        if(c==null)
            continue;   // no customization --- nothing to inject here

        c.markAsAcknowledged();
        // TODO: ideally you should validate this DOM element to make sure
        // that there's no typo/etc. JAXP 1.3 can do this very easily.
        String codeFragment = DOMUtils.getElementText(c.element);

        // inject the specified code fragment into the implementation class.
        co.implClass.direct(codeFragment);
    }

    return true;
}
 
示例16
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
示例17
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
示例18
public boolean run(
    Outline outline,
    Options opt,
    ErrorHandler errorHandler ) {

    for( ClassOutline ci : outline.getClasses() ) {
        JDefinedClass impl = ci.implClass;
        if (ci.getSuperClass() == null) {
            JVar $loc = impl.field(JMod.PROTECTED, Locator.class, fieldName);
            $loc.annotate(XmlLocation.class);
            $loc.annotate(XmlTransient.class);

            impl._implements(Locatable.class);

            impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc);

            JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation");
            JVar $newLoc = setter.param(Locator.class, "newLocator");
            setter.body().assign($loc, $newLoc);
        }
    }

    return true;
}
 
示例19
public boolean run(
    Outline outline,
    Options opt,
    ErrorHandler errorHandler ) {

    for( ClassOutline ci : outline.getClasses() ) {
        JDefinedClass impl = ci.implClass;
        if (ci.getSuperClass() == null) {
            JVar $loc = impl.field(JMod.PROTECTED, Locator.class, fieldName);
            $loc.annotate(XmlLocation.class);
            $loc.annotate(XmlTransient.class);

            impl._implements(Locatable.class);

            impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc);

            JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation");
            JVar $newLoc = setter.param(Locator.class, "newLocator");
            setter.body().assign($loc, $newLoc);
        }
    }

    return true;
}
 
示例20
/**
 * @param nc
 *      Usually this should be set in the constructor, but we do allow this parameter
 *      to be initially null, and then set later.
 * @param schemaComponent
 *      The source schema model, if this is built from XSD.
 */
public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) {
    this.options = opts;
    this.codeModel = cm;
    this.nameConverter = nc;
    this.defaultSymbolSpace = new SymbolSpace(codeModel);
    defaultSymbolSpace.setType(codeModel.ref(Object.class));

    elementMappings.put(null,new HashMap<QName,CElementInfo>());

    if(opts.automaticNameConflictResolution)
        allocator = new AutoClassNameAllocator(allocator);
    this.allocator = new ClassNameAllocatorWrapper(allocator);
    this.schemaComponent = schemaComponent;
    this.gloablCustomizations.setParent(this,this);
}
 
示例21
public boolean run( Outline model, Options opt, ErrorHandler errorHandler ) {
    // we want this to work without requiring JSR-250 jar.
    annotation = model.getCodeModel().ref("javax.annotation.Generated");

    for( ClassOutline co : model.getClasses() )
        augument(co);
    for( EnumOutline eo : model.getEnums() )
        augument(eo);

    //TODO: process generated ObjectFactory classes?

    return true;
}
 
示例22
/**
 * @param handler
 *      This error handler will receive detected errors.
 */
public AbstractExtensionBindingChecker( String schemaLanguage, Options options, ErrorHandler handler ) {
    this.schemaLanguage = schemaLanguage;
    this.allowExtensions = options.compatibilityMode!=Options.STRICT;
    this.options = options;
    setErrorHandler(handler);

    for (Plugin plugin : options.getAllPlugins())
        recognizableExtensions.addAll(plugin.getCustomizationURIs());
    recognizableExtensions.add(Const.XJC_EXTENSION_URI);
}
 
示例23
public boolean run( Outline model, Options opt, ErrorHandler errorHandler ) {
    // we want this to work without requiring JSR-250 jar.
    annotation = model.getCodeModel().ref("javax.annotation.Generated");

    for( ClassOutline co : model.getClasses() )
        augument(co);
    for( EnumOutline eo : model.getEnums() )
        augument(eo);

    //TODO: process generated ObjectFactory classes?

    return true;
}
 
示例24
public DOMForest( InternalizationLogic logic, Options opt ) {

        if (opt == null) throw new AssertionError("Options object null");
        this.options = opt;

        try {
            DocumentBuilderFactory dbf = XmlFactory.createDocumentBuilderFactory(opt.disableXmlSecurity);
            this.documentBuilder = dbf.newDocumentBuilder();
            this.parserFactory = XmlFactory.createParserFactory(opt.disableXmlSecurity);
        } catch( ParserConfigurationException e ) {
            throw new AssertionError(e);
        }

        this.logic = logic;
    }
 
示例25
public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException {
    if(args[i].equals("-episode")) {
        episodeFile = new File(opt.requireArgument("-episode",args,++i));
        return 2;
    }
    return 0;
}
 
示例26
public boolean run( Outline model, Options opt, ErrorHandler errorHandler ) {
    // we want this to work without requiring JSR-250 jar.
    annotation = model.getCodeModel().ref("javax.annotation.Generated");

    for( ClassOutline co : model.getClasses() )
        augument(co);
    for( EnumOutline eo : model.getEnums() )
        augument(eo);

    //TODO: process generated ObjectFactory classes?

    return true;
}
 
示例27
/**
 * @param handler
 *      This error handler will receive detected errors.
 */
public AbstractExtensionBindingChecker( String schemaLanguage, Options options, ErrorHandler handler ) {
    this.schemaLanguage = schemaLanguage;
    this.allowExtensions = options.compatibilityMode!=Options.STRICT;
    this.options = options;
    setErrorHandler(handler);

    for (Plugin plugin : options.getAllPlugins())
        recognizableExtensions.addAll(plugin.getCustomizationURIs());
    recognizableExtensions.add(Const.XJC_EXTENSION_URI);
}
 
示例28
protected TDTDReader(ErrorReceiver errorReceiver, Options opts, InputSource _bindInfo)
    throws AbortException {
    this.entityResolver = opts.entityResolver;
    this.errorReceiver = new ErrorReceiverFilter(errorReceiver);
    bindInfo = new BindInfo(model,_bindInfo, this.errorReceiver);
    classFactory = new CodeModelClassFactory(errorReceiver);
}
 
示例29
public DOMForest( InternalizationLogic logic, Options opt ) {

        if (opt == null) throw new AssertionError("Options object null");
        this.options = opt;

        try {
            DocumentBuilderFactory dbf = XmlFactory.createDocumentBuilderFactory(opt.disableXmlSecurity);
            this.documentBuilder = dbf.newDocumentBuilder();
            this.parserFactory = XmlFactory.createParserFactory(opt.disableXmlSecurity);
        } catch( ParserConfigurationException e ) {
            throw new AssertionError(e);
        }

        this.logic = logic;
    }
 
示例30
public boolean run( Outline model, Options opt, ErrorHandler errorHandler ) {
    // we want this to work without requiring JSR-250 jar.
    annotation = model.getCodeModel().ref("javax.annotation.Generated");

    for( ClassOutline co : model.getClasses() )
        augument(co);
    for( EnumOutline eo : model.getEnums() )
        augument(eo);

    //TODO: process generated ObjectFactory classes?

    return true;
}