FileDocCategorySizeDatePackage
EnvEntryImpl.javaAPI DocExample19988Thu Mar 07 09:13:52 GMT 2002javajaxb.generated.web

EnvEntryImpl

public class EnvEntryImpl extends DefaultHandler implements LexicalHandler, Unmarshallable, EnvEntry
This class was generated from a set of XML constraints by the Enhydra Zeus XML Data Binding Framework. All source code in this file is constructed specifically to work with other Zeus-generated classes. If you modify this file by hand, you run the risk of breaking this interoperation, as well as introducing errors in source code compilation. * * * * MODIFY THIS FILE AT YOUR OWN RISK * * * * * To find out more about the Enhydra Zeus framework, you can point your browser at where you can download releases, join and discuss Zeus on user and developer mailing lists, and access source code. Please report any bugs through that website.

Fields Summary
private String
description
private boolean
zeus_DescriptionSet
private String
envEntryName
private boolean
zeus_EnvEntryNameSet
private String
envEntryValue
private boolean
zeus_EnvEntryValueSet
private String
envEntryType
private boolean
zeus_EnvEntryTypeSet
private String
id
private boolean
zeus_IdSet
private String
docTypeString
Any DOCTYPE reference/statements.
private String
outputEncoding
The encoding for the output document
private Unmarshallable
zeus_currentUNode
The current node in unmarshalling
private Unmarshallable
zeus_parentUNode
The parent node in unmarshalling
private boolean
zeus_thisNodeHandled
Whether this node has been handled
private boolean
hasDTD
Whether a DTD exists for an unmarshal call
private boolean
validate
Whether validation is occurring
private Map
namespaceMappings
The namespace mappings on this element
private static EntityResolver
entityResolver
The EntityResolver for SAX parsing to use
private static ErrorHandler
errorHandler
The ErrorHandler for SAX parsing to use
private boolean
zeus_inDescription
Indicates if we are in the description element
private boolean
zeus_inEnvEntryName
Indicates if we are in the envEntryName element
private boolean
zeus_inEnvEntryValue
Indicates if we are in the envEntryValue element
private boolean
zeus_inEnvEntryType
Indicates if we are in the envEntryType element
Constructors Summary
public EnvEntryImpl()


      
        zeus_DescriptionSet = false;
        zeus_EnvEntryNameSet = false;
        zeus_EnvEntryValueSet = false;
        zeus_EnvEntryTypeSet = false;
        zeus_IdSet = false;
        docTypeString = "";
        hasDTD = false;
        validate = false;
        namespaceMappings = new HashMap();
    
Methods Summary
public voidcharacters(char[] ch, int start, int len)


        // Feed this to the correct ContentHandler
        Unmarshallable current = getCurrentUNode();
        if (current != this) {
            current.characters(ch, start, len);
            return;
        }

        String text = new String(ch, start, len);
        text = text.trim();
        if (zeus_inDescription) {
            if (this.description == null) {
                this.description = text;
            } else {
                this.description = new StringBuffer(this.description).append(text).toString();
            }
            return;
        }

        if (zeus_inEnvEntryName) {
            if (this.envEntryName == null) {
                this.envEntryName = text;
            } else {
                this.envEntryName = new StringBuffer(this.envEntryName).append(text).toString();
            }
            return;
        }

        if (zeus_inEnvEntryValue) {
            if (this.envEntryValue == null) {
                this.envEntryValue = text;
            } else {
                this.envEntryValue = new StringBuffer(this.envEntryValue).append(text).toString();
            }
            return;
        }

        if (zeus_inEnvEntryType) {
            if (this.envEntryType == null) {
                this.envEntryType = text;
            } else {
                this.envEntryType = new StringBuffer(this.envEntryType).append(text).toString();
            }
            return;
        }

    
public voidcomment(char[] ch, int start, int len)

        // Currently no-op
    
public voidendCDATA()

        // Currently no-op
    
public voidendDTD()

        // Currently no-op
    
public voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)


        Unmarshallable current = getCurrentUNode();
        if (current != this) {
            current.endElement(namespaceURI, localName, qName);
            return;
        }

        if (localName.equals("description")) {
            this.zeus_inDescription = false;
            return;
        }

        if (localName.equals("env-entry-name")) {
            this.zeus_inEnvEntryName = false;
            return;
        }

        if (localName.equals("env-entry-value")) {
            this.zeus_inEnvEntryValue = false;
            return;
        }

        if (localName.equals("env-entry-type")) {
            this.zeus_inEnvEntryType = false;
            return;
        }

        Unmarshallable parent = getCurrentUNode().getParentUNode();
        if (parent != null) {
            parent.setCurrentUNode(parent);
        }
    
public voidendEntity(java.lang.String name)

        // Currently no-op
    
public voiderror(org.xml.sax.SAXParseException e)

        if ((validate) && (!hasDTD)) {
            throw new SAXException("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");
        }
        if (errorHandler != null) {
            errorHandler.error(e);
        }
    
private java.lang.StringescapeAttributeValue(java.lang.String attributeValue)


        
        String returnValue = attributeValue;
        for (int i = 0; i < returnValue.length(); i++) {
            char ch = returnValue.charAt(i);
            if (ch == '"") {
                returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append(""")
                    .append(returnValue.substring(i+1))
                    .toString();
            }
        }
        return returnValue;
    
private java.lang.StringescapeTextValue(java.lang.String textValue)

        String returnValue = textValue;
        for (int i = 0; i < returnValue.length(); i++) {
            char ch = returnValue.charAt(i);
            if (ch == '<") {
                returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append("<")
                    .append(returnValue.substring(i+1))
                    .toString();
            } else if (ch == '>") {
                returnValue = new StringBuffer()
                    .append(returnValue.substring(0, i))
                    .append(">")
                    .append(returnValue.substring(i+1))
                    .toString();
            }
        }
        return returnValue;
    
public voidfatalError(org.xml.sax.SAXParseException e)

        if ((validate) && (!hasDTD)) {
            throw new SAXException("Validation is turned on, but no DTD has been specified in the input XML document. Please supply a DTD through a DOCTYPE reference.");
        }
        if (errorHandler != null) {
            errorHandler.fatalError(e);
        }
    
public UnmarshallablegetCurrentUNode()

        return zeus_currentUNode;
    
public java.lang.StringgetDescription()

        return description;
    
public java.lang.StringgetEnvEntryName()

        return envEntryName;
    
public java.lang.StringgetEnvEntryType()

        return envEntryType;
    
public java.lang.StringgetEnvEntryValue()

        return envEntryValue;
    
public java.lang.StringgetId()

        return id;
    
public UnmarshallablegetParentUNode()

        return zeus_parentUNode;
    
public voidmarshal(java.io.File file)

        // Delegate to the marshal(Writer) method
        marshal(new FileWriter(file));
    
public voidmarshal(java.io.OutputStream outputStream)

        // Delegate to the marshal(Writer) method
        marshal(new OutputStreamWriter(outputStream));
    
public voidmarshal(java.io.Writer writer)

        // Write out the XML declaration
        writer.write("<?xml version=\"1.0\" ");
        if (outputEncoding != null) {
            writer.write("encoding=\"");
            writer.write(outputEncoding);
            writer.write("\"?>\n\n");

        } else {
            writer.write("encoding=\"UTF-8\"?>\n\n");

        }
        // Handle DOCTYPE declaration
        writer.write(docTypeString);
        writer.write("\n");
        // Now start the recursive writing
        writeXMLRepresentation(writer, "");

        // Close up
        writer.flush();
        writer.close();
    
public voidsetCurrentUNode(Unmarshallable currentUNode)

        this.zeus_currentUNode = currentUNode;
    
public voidsetDescription(java.lang.String description)

        this.description = description;
        zeus_DescriptionSet = true;
    
public voidsetDocType(java.lang.String name, java.lang.String publicID, java.lang.String systemID)

        try {
            startDTD(name, publicID, systemID);
        } catch (SAXException neverHappens) { }
    
public voidsetDocumentLocator(org.xml.sax.Locator locator)

        // no-op
    
public static voidsetEntityResolver(org.xml.sax.EntityResolver resolver)

This sets a SAX EntityResolver for this unmarshalling process.

param
resolver the entity resolver to use.

        entityResolver = resolver;
    
public voidsetEnvEntryName(java.lang.String envEntryName)

        this.envEntryName = envEntryName;
        zeus_EnvEntryNameSet = true;
    
public voidsetEnvEntryType(java.lang.String envEntryType)

        this.envEntryType = envEntryType;
        zeus_EnvEntryTypeSet = true;
    
public voidsetEnvEntryValue(java.lang.String envEntryValue)

        this.envEntryValue = envEntryValue;
        zeus_EnvEntryValueSet = true;
    
public static voidsetErrorHandler(org.xml.sax.ErrorHandler handler)

This sets a SAX ErrorHandler for this unmarshalling process.

param
handler the entity resolver to use.

        errorHandler = handler;
    
public voidsetId(java.lang.String id)

        this.id = id;
        zeus_IdSet = true;
    
public voidsetOutputEncoding(java.lang.String outputEncoding)

        this.outputEncoding = outputEncoding;
    
public voidsetParentUNode(Unmarshallable parentUNode)

        this.zeus_parentUNode = parentUNode;
    
public voidsetValidating(boolean validate)

        this.validate = validate;
    
public voidstartCDATA()

        // Currently no-op
    
public voidstartDTD(java.lang.String name, java.lang.String publicID, java.lang.String systemID)


        if ((name == null) || (name.equals(""))) {
            docTypeString = "";
            return;
        }

        hasDTD = true;
        StringBuffer docTypeSB = new StringBuffer();
        boolean hasPublic = false;

        docTypeSB.append("<!DOCTYPE ")
                 .append(name);

        if ((publicID != null) && (!publicID.equals(""))) {
            docTypeSB.append(" PUBLIC \"")
                     .append(publicID)
                     .append("\"");
            hasPublic = true;
        }

        if ((systemID != null) && (!systemID.equals(""))) {
            if (!hasPublic) {
                docTypeSB.append(" SYSTEM");
            }
            docTypeSB.append(" \"")
                     .append(systemID)
                     .append("\"");

        }

        docTypeSB.append(">");

        docTypeString = docTypeSB.toString();
    
public voidstartDocument()

        // no-op
    
public voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)


        // Feed this to the correct ContentHandler
        Unmarshallable current = getCurrentUNode();
        if (current != this) {
            current.startElement(namespaceURI, localName, qName, atts);
            return;
        }

        // See if we handle, or we delegate
        if ((localName.equals("env-entry")) && (!zeus_thisNodeHandled)) {
            // Handle ourselves
            for (int i=0, len=atts.getLength(); i<len; i++) {
                String attName= atts.getLocalName(i);
                String attValue = atts.getValue(i);
                if (attName.equals("id")) {
                    setId(attValue);
                }
            }
            zeus_thisNodeHandled = true;
            return;
        } else {
            // Delegate handling
            if (localName.equals("description")) {
                this.zeus_inDescription = true;
                return;
            }
            if (localName.equals("env-entry-name")) {
                this.zeus_inEnvEntryName = true;
                return;
            }
            if (localName.equals("env-entry-value")) {
                this.zeus_inEnvEntryValue = true;
                return;
            }
            if (localName.equals("env-entry-type")) {
                this.zeus_inEnvEntryType = true;
                return;
            }
        }
    
public voidstartEntity(java.lang.String name)

        // Currently no-op
    
public voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)

        namespaceMappings.put(prefix, uri);
    
public static EnvEntryunmarshal(java.io.File file)

        // Delegate to the unmarshal(Reader) method
        return unmarshal(new FileReader(file));
    
public static EnvEntryunmarshal(java.io.File file, boolean validate)

        // Delegate to the unmarshal(Reader) method
        return unmarshal(new FileReader(file), validate);
    
public static EnvEntryunmarshal(java.io.InputStream inputStream)

        // Delegate to the unmarshal(Reader) method
        return unmarshal(new InputStreamReader(inputStream));
    
public static EnvEntryunmarshal(java.io.InputStream inputStream, boolean validate)

        // Delegate to the unmarshal(Reader) method
        return unmarshal(new InputStreamReader(inputStream), validate);
    
public static EnvEntryunmarshal(java.io.Reader reader)

        // Delegate with default validation value
        return unmarshal(reader, false);
    
public static EnvEntryunmarshal(java.io.Reader reader, boolean validate)

        EnvEntryImpl envEntry = new EnvEntryImpl();
        envEntry.setValidating(validate);
        envEntry.setCurrentUNode(envEntry);
        envEntry.setParentUNode(null);
        // Load the XML parser
        XMLReader parser = null;
        String parserClass = System.getProperty("org.xml.sax.driver",
            "org.apache.xerces.parsers.SAXParser");
        try {
            parser = XMLReaderFactory.createXMLReader(parserClass);

            // Set entity resolver, if needed
            if (entityResolver != null) {
                parser.setEntityResolver(entityResolver);
            }

            // Set error handler
            parser.setErrorHandler(envEntry);

            // Register lexical handler
            parser.setProperty("http://xml.org/sax/properties/lexical-handler", envEntry);

            // Register content handler
            parser.setContentHandler(envEntry);
        } catch (SAXException e) {
            throw new IOException("Could not load XML parser: " + 
                e.getMessage());
        }

        InputSource inputSource = new InputSource(reader);
        try {
            parser.setFeature("http://xml.org/sax/features/validation", new Boolean(validate).booleanValue());
            parser.setFeature("http://xml.org/sax/features/namespaces", true);
            parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
            parser.parse(inputSource);
        } catch (SAXException e) {
            throw new IOException("Error parsing XML document: " + 
                e.getMessage());
        }

        // Return the resultant object
        return envEntry;
    
public voidwarning(org.xml.sax.SAXParseException e)

        if (errorHandler != null) {
            errorHandler.warning(e);
        }
    
protected voidwriteXMLRepresentation(java.io.Writer writer, java.lang.String indent)


        writer.write(indent);
        writer.write("<env-entry");

        // Handle namespace mappings (if needed)
        for (Iterator i = namespaceMappings.keySet().iterator(); i.hasNext(); ) {
            String prefix = (String)i.next();
            String uri = (String)namespaceMappings.get(prefix);
            writer.write(" xmlns");
            if (!prefix.trim().equals("")) {
                writer.write(":");
                writer.write(prefix);
            }
            writer.write("=\"");
            writer.write(uri);
            writer.write("\"\n        ");
        }

        // Handle attributes (if needed)
        if (zeus_IdSet) {
            writer.write(" id=\"");
            writer.write(escapeAttributeValue(id));
            writer.write("\"");
        }
        writer.write(">");
        writer.write("\n");

        // Handle child elements
        if (description != null) {
            writer.write(new StringBuffer(indent).append("  ").toString());
            writer.write("<description>");
            writer.write(this.description);
            writer.write("</description>\n");
        }

        if (envEntryName != null) {
            writer.write(new StringBuffer(indent).append("  ").toString());
            writer.write("<env-entry-name>");
            writer.write(this.envEntryName);
            writer.write("</env-entry-name>\n");
        }

        if (envEntryValue != null) {
            writer.write(new StringBuffer(indent).append("  ").toString());
            writer.write("<env-entry-value>");
            writer.write(this.envEntryValue);
            writer.write("</env-entry-value>\n");
        }

        if (envEntryType != null) {
            writer.write(new StringBuffer(indent).append("  ").toString());
            writer.write("<env-entry-type>");
            writer.write(this.envEntryType);
            writer.write("</env-entry-type>\n");
        }

        writer.write(indent);
        writer.write("</env-entry>\n");