msv.tahiti.src.com.sun.tahiti.compiler.java.ClassSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaxb1-impl Show documentation
Show all versions of jaxb1-impl Show documentation
JAXB (JSR 222) Reference Implementation - JAXB1 build
/*
* @(#)$Id: ClassSerializer.java 1087 2001-08-18 01:37:50Z Bear $
*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/
package com.sun.tahiti.compiler.java;
import com.sun.msv.grammar.*;
import com.sun.tahiti.compiler.Symbolizer;
import com.sun.tahiti.compiler.Controller;
import com.sun.tahiti.compiler.XMLWriter;
import com.sun.tahiti.compiler.sm.MarshallerGenerator;
import com.sun.tahiti.grammar.*;
import com.sun.tahiti.grammar.util.Multiplicity;
import com.sun.tahiti.reader.NameUtil;
import com.sun.tahiti.util.text.Formatter;
import com.sun.tahiti.util.xml.XSLTUtil;
import com.sun.tahiti.util.xml.DOMVisitor;
import com.sun.tahiti.util.xml.DOMBuilder;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import java.text.MessageFormat;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
/**
* produces Java source codes of the object model.
*
* @author
* Kohsuke KAWAGUCHI
*/
public class ClassSerializer
{
public ClassSerializer( AnnotatedGrammar grammar, Symbolizer symbolizer, Controller controller ) {
this.grammar = grammar;
this.symbolizer = symbolizer;
this.controller = controller;
this.grammarClassName = grammar.grammarName;
int idx = grammarClassName.lastIndexOf('.');
if(idx<0) grammarShortClassName = grammarClassName;
else grammarShortClassName = grammarClassName.substring(idx+1);
}
private final AnnotatedGrammar grammar;
private final Symbolizer symbolizer;
private final Controller controller;
/** fully-qualified name of the Gramamr class. */
protected final String grammarClassName;
/**
* bare class name of the Grammar class.
* Since the Grammar class is imported in generated classes,
* this bare name can be used to refer to the Grammar class.
*/
protected final String grammarShortClassName;
public void generate() throws IOException {
// collect all ClassItems.
ClassItem[] types = grammar.getClasses();
for( int i=0; ilist of derived types");
hasDerivedType |= listDerivedTypes(type,grammar.iterateClasses());
hasDerivedType |= listDerivedTypes(type,grammar.iterateInterfaces());
if(!hasDerivedType)
out.println(" * no derived type");
out.println(" */");
}
protected boolean listDerivedTypes( TypeItem current, Iterator itr ) {
boolean hasDerivedType = false;
while( itr.hasNext() ) {
TypeItem type = (TypeItem)itr.next();
boolean isDerived = false;
if(type.getSuperType()==current)
isDerived = true;
Type[] itfs = type.getInterfaces();
for( int i=0; i