You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2002/03/08 06:11:24 UTC
cvs commit: xml-axis/java/src/org/apache/axis/description TypeDesc.java
gdaniels 02/03/07 21:11:24
Modified: java/src/org/apache/axis/description TypeDesc.java
Log:
add javadoc/license
Revision Changes Path
1.2 +99 -4 xml-axis/java/src/org/apache/axis/description/TypeDesc.java
Index: TypeDesc.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/TypeDesc.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TypeDesc.java 8 Mar 2002 05:04:53 -0000 1.1
+++ TypeDesc.java 8 Mar 2002 05:11:24 -0000 1.2
@@ -1,3 +1,57 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Axis" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
package org.apache.axis.description;
@@ -5,17 +59,33 @@
import java.util.HashMap;
import java.lang.reflect.Array;
+/**
+ * A TypeDesc represents a Java<->XML data binding. It is essentially
+ * a collection of FieldDescs describing how to map each field in a Java
+ * class to XML.
+ *
+ * @author Glen Daniels (gdaniels@apache.org)
+ */
public class TypeDesc {
private FieldDesc [] fields;
+
+ /** A cache of FieldDescs by name */
private HashMap fieldNameMap = new HashMap();
/** Are there any fields which are serialized as attributes? */
private boolean _hasAttributes = false;
+ /**
+ * Obtain the current array of FieldDescs
+ */
public FieldDesc[] getFields() {
return fields;
}
+ /**
+ * Replace the array of FieldDescs, making sure we keep our convenience
+ * caches in sync.
+ */
public void setFields(FieldDesc [] newFields)
{
fieldNameMap = new HashMap();
@@ -31,7 +101,10 @@
}
}
}
-
+
+ /**
+ * Add a new FieldDesc, keeping the convenience fields in sync.
+ */
public void addFieldDesc(FieldDesc field)
{
if (field == null)
@@ -54,7 +127,11 @@
if (!_hasAttributes && !field.isElement())
_hasAttributes = true;
}
-
+
+ /**
+ * Get the QName associated with this field, but only if it's
+ * marked as an element.
+ */
public QName getElementNameForField(String fieldName)
{
FieldDesc desc = (FieldDesc)fieldNameMap.get(fieldName);
@@ -63,6 +140,10 @@
return desc.getXmlName();
}
+ /**
+ * Get the QName associated with this field, but only if it's
+ * marked as an attribute.
+ */
public QName getAttributeNameForField(String fieldName)
{
FieldDesc desc = (FieldDesc)fieldNameMap.get(fieldName);
@@ -70,7 +151,11 @@
return null;
return desc.getXmlName();
}
-
+
+ /**
+ * Get the field name associated with this QName, but only if it's
+ * marked as an element.
+ */
public String getFieldNameForElement(QName qname)
{
for (int i = 0; i < fields.length; i++) {
@@ -82,6 +167,10 @@
return null;
}
+ /**
+ * Get the field name associated with this QName, but only if it's
+ * marked as an attribute.
+ */
public String getFieldNameForAttribute(QName qname)
{
String possibleMatch = null;
@@ -105,12 +194,18 @@
return possibleMatch;
}
-
+
+ /**
+ * Get a FieldDesc by field name.
+ */
public FieldDesc getFieldByName(String name)
{
return (FieldDesc)fieldNameMap.get(name);
}
+ /**
+ * Do we have any FieldDescs marked as attributes?
+ */
public boolean hasAttributes() {
return _hasAttributes;
}