|
Java example source code file (BIElement.java)
The BIElement.java Java example source code/* * Copyright (c) 1997, 2011, 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.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.xml.namespace.QName; import com.sun.tools.internal.xjc.model.CClassInfo; import com.sun.xml.internal.bind.api.impl.NameConverter; import org.w3c.dom.Element; import org.xml.sax.Locator; /** * <element> declaration in the binding file. */ public final class BIElement { /** * Wraps a given <element> element in the binding file. * * <p> * Should be created only from {@link BindInfo}. */ BIElement( BindInfo bi, Element _e ) { this.parent = bi; this.e = _e; { Element c = DOMUtil.getElement(e,"content"); if(c!=null) { if(DOMUtil.getAttribute(c,"property")!=null) { // if @property is there, this is a general declaration this.rest = BIContent.create(c,this); } else { // this must be a model-based declaration for( Element p : DOMUtil.getChildElements(c) ) { if(p.getLocalName().equals("rest")) this.rest = BIContent.create(p,this); else this.contents.add(BIContent.create(p,this)); } } } } // parse <attribute>s for( Element atr : DOMUtil.getChildElements(e,"attribute") ) { BIAttribute a = new BIAttribute( this, atr ); attributes.put(a.name(),a); } if(isClass()) { // if this is a class-declaration, create JClass object now String className = DOMUtil.getAttribute(e,"class"); if(className==null) // none was specified. infer the name. className = NameConverter.standard.toClassName(name()); this.className = className; } else { // this is not an element-class declaration className = null; } // process conversion declarations for( Element conv : DOMUtil.getChildElements(e,"conversion") ) { BIConversion c = new BIUserConversion(bi,conv); conversions.put(c.name(),c); } for( Element en : DOMUtil.getChildElements(e,"enumeration") ) { BIConversion c = BIEnumeration.create(en,this); conversions.put(c.name(),c); } // parse <constructor>s for( Element c : DOMUtil.getChildElements(e,"constructor") ) { constructors.add( new BIConstructor(c) ); } String name = name(); QName tagName = new QName("",name); this.clazz = new CClassInfo(parent.model,parent.getTargetPackage(),className,getLocation(),null,tagName,null,null/*TODO*/); } /** * Gets the source location where this element is declared. */ public Locator getLocation() { return DOMLocator.getLocationInfo(e); } /** The parent {@link BindInfo} object to which this object belongs. */ final BindInfo parent; /** <element> element which this object is wrapping. */ private final Element e; /** * The bean representation for this element. */ public final CClassInfo clazz; /** * Content-property declarations. * <p> * This vector will be empty if no content-property declaration is made. */ private final List<BIContent> contents = new ArrayList Other Java examples (source code examples)Here is a short list of links related to this Java BIElement.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.