|
Java example source code file (BindInfo.java)
The BindInfo.java Java example source code/* * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.internal.xjc.reader.dtd.bindinfo; import java.io.IOException; import java.util.Collection; import java.util.HashMap; import java.util.Map; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParserFactory; import javax.xml.validation.ValidatorHandler; import com.sun.codemodel.internal.ClassType; import com.sun.codemodel.internal.JClass; import com.sun.codemodel.internal.JClassAlreadyExistsException; import com.sun.codemodel.internal.JCodeModel; import com.sun.codemodel.internal.JDefinedClass; import com.sun.codemodel.internal.JPackage; import com.sun.istack.internal.SAXParseException2; import com.sun.tools.internal.xjc.AbortException; import com.sun.tools.internal.xjc.ErrorReceiver; import com.sun.tools.internal.xjc.SchemaCache; import com.sun.tools.internal.xjc.model.CCustomizations; import com.sun.tools.internal.xjc.model.CPluginCustomization; import com.sun.tools.internal.xjc.model.Model; import com.sun.tools.internal.xjc.reader.Const; import com.sun.tools.internal.xjc.util.CodeModelClassFactory; import com.sun.tools.internal.xjc.util.ErrorReceiverFilter; import com.sun.tools.internal.xjc.util.ForkContentHandler; import com.sun.xml.internal.bind.v2.util.XmlFactory; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** * Root of the binding information. */ public class BindInfo { /** Controller object that can be used to report errors. */ protected final ErrorReceiver errorReceiver; /*package*/ final Model model; /** * The -p option that should control the default Java package that * will contain the generated code. Null if unspecified. This takes * precedence over the value specified in the binding file. */ private final String defaultPackage; public BindInfo(Model model, InputSource source, ErrorReceiver _errorReceiver) throws AbortException { this( model, parse(model,source,_errorReceiver), _errorReceiver); } public BindInfo(Model model, Document _dom, ErrorReceiver _errorReceiver) { this.model = model; this.dom = _dom.getDocumentElement(); this.codeModel = model.codeModel; this.errorReceiver = _errorReceiver; this.classFactory = new CodeModelClassFactory(_errorReceiver); // TODO: decide name converter from the binding file this.defaultPackage = model.options.defaultPackage; // copy global customizations to the model model.getCustomizations().addAll(getGlobalCustomizations()); // process element declarations for( Element ele : DOMUtil.getChildElements(dom,"element")) { BIElement e = new BIElement(this,ele); elements.put(e.name(),e); } // add built-in conversions BIUserConversion.addBuiltinConversions(this,conversions); // process conversion declarations for( Element cnv : DOMUtil.getChildElements(dom,"conversion")) { BIConversion c = new BIUserConversion(this,cnv); conversions.put(c.name(),c); } for( Element en : DOMUtil.getChildElements(dom,"enumeration")) { BIConversion c = BIEnumeration.create( en, this ); conversions.put(c.name(),c); } // TODO: check the uniquness of conversion name // process interface definitions for( Element itf : DOMUtil.getChildElements(dom,"interface")) { BIInterface c = new BIInterface(itf); interfaces.put(c.name(),c); } } /** CodeModel object that is used by this binding file. */ final JCodeModel codeModel; /** Wrap the codeModel object and automate error reporting. */ final CodeModelClassFactory classFactory; /** DOM tree that represents binding info. */ private final Element dom; /** Conversion declarations. */ private final Map<String,BIConversion> conversions = new HashMap Other Java examples (source code examples)Here is a short list of links related to this Java BindInfo.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.