alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/**
 *	This generated bean class SchemaTypeMappingType
 *	matches the schema element 'schemaTypeMappingType'.
 *  The root bean class is BeanGraph
 *
 *	===============================================================
 *	
 *			Map between schema types and java types.
 *		  
 *	===============================================================
 * @Generated
 */

package org.netbeans.modules.schema2beansdev.beangraph;

public class SchemaTypeMappingType implements org.netbeans.modules.schema2beansdev.beangraph.CommonBean {
	public static final String SCHEMA_TYPE_NAMESPACE = "SchemaTypeNamespace";	// NOI18N
	public static final String SCHEMA_TYPE_NAME = "SchemaTypeName";	// NOI18N
	public static final String JAVA_TYPE = "JavaType";	// NOI18N
	public static final String ROOT = "Root";	// NOI18N
	public static final String BEAN = "Bean";	// NOI18N
	public static final String CAN_BE_EMPTY = "CanBeEmpty";	// NOI18N

	private java.lang.String _SchemaTypeNamespace;
	private java.lang.String _SchemaTypeName;
	private java.lang.String _JavaType;
	private boolean _Root;
	private boolean _Bean;
	private boolean _CanBeEmpty;

	/**
	 * Normal starting point constructor.
	 */
	public SchemaTypeMappingType() {
		_SchemaTypeName = "";
		_JavaType = "";
	}

	/**
	 * Required parameters constructor
	 */
	public SchemaTypeMappingType(java.lang.String schemaTypeName, java.lang.String javaType) {
		_SchemaTypeName = schemaTypeName;
		_JavaType = javaType;
	}

	/**
	 * Deep copy
	 */
	public SchemaTypeMappingType(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType source) {
		this(source, false);
	}

	/**
	 * Deep copy
	 * @param justData just copy the XML relevant data
	 */
	public SchemaTypeMappingType(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType source, boolean justData) {
		_SchemaTypeNamespace = source._SchemaTypeNamespace;
		_SchemaTypeName = source._SchemaTypeName;
		_JavaType = source._JavaType;
		_Root = source._Root;
		_Bean = source._Bean;
		_CanBeEmpty = source._CanBeEmpty;
	}

	// This attribute is optional
	public void setSchemaTypeNamespace(java.lang.String value) {
		_SchemaTypeNamespace = value;
	}

	public java.lang.String getSchemaTypeNamespace() {
		return _SchemaTypeNamespace;
	}

	// This attribute is mandatory
	public void setSchemaTypeName(java.lang.String value) {
		_SchemaTypeName = value;
	}

	public java.lang.String getSchemaTypeName() {
		return _SchemaTypeName;
	}

	// This attribute is mandatory
	public void setJavaType(java.lang.String value) {
		_JavaType = value;
	}

	public java.lang.String getJavaType() {
		return _JavaType;
	}

	// This attribute is optional
	public void setRoot(boolean value) {
		_Root = value;
	}

	public boolean isRoot() {
		return _Root;
	}

	// This attribute is optional
	public void setBean(boolean value) {
		_Bean = value;
	}

	public boolean isBean() {
		return _Bean;
	}

	// This attribute is optional
	public void setCanBeEmpty(boolean value) {
		_CanBeEmpty = value;
	}

	public boolean isCanBeEmpty() {
		return _CanBeEmpty;
	}

	public void writeNode(java.io.Writer out) throws java.io.IOException {
		String myName;
		myName = "schemaTypeMappingType";
		writeNode(out, myName, "");	// NOI18N
	}

	public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException {
		writeNode(out, nodeName, null, indent, new java.util.HashMap());
	}

	/**
	 * It's not recommended to call this method directly.
	 */
	public void writeNode(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException {
		out.write(indent);
		out.write("<");
		if (namespace != null) {
			out.write((String)namespaceMap.get(namespace));
			out.write(":");
		}
		out.write(nodeName);
		out.write(">\n");
		String nextIndent = indent + "	";
		if (_SchemaTypeNamespace != null) {
			out.write(nextIndent);
			out.write("");	// NOI18N
			org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _SchemaTypeNamespace, false);
			out.write("\n");	// NOI18N
		}
		if (_SchemaTypeName != null) {
			out.write(nextIndent);
			out.write("");	// NOI18N
			org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _SchemaTypeName, false);
			out.write("\n");	// NOI18N
		}
		if (_JavaType != null) {
			out.write(nextIndent);
			out.write("");	// NOI18N
			org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _JavaType, false);
			out.write("\n");	// NOI18N
		}
		out.write(nextIndent);
		out.write("");	// NOI18N
		out.write(_Root ? "true" : "false");
		out.write("\n");	// NOI18N
		out.write(nextIndent);
		out.write("");	// NOI18N
		out.write(_Bean ? "true" : "false");
		out.write("\n");	// NOI18N
		out.write(nextIndent);
		out.write("");	// NOI18N
		out.write(_CanBeEmpty ? "true" : "false");
		out.write("\n");	// NOI18N
		out.write(indent);
		out.write("\n");
	}

	public void readNode(org.w3c.dom.Node node) {
		readNode(node, new java.util.HashMap());
	}

	public void readNode(org.w3c.dom.Node node, java.util.Map namespacePrefixes) {
		if (node.hasAttributes()) {
			org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
			org.w3c.dom.Attr attr;
			java.lang.String attrValue;
			boolean firstNamespaceDef = true;
			for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
				attr = (org.w3c.dom.Attr) attrs.item(attrNum);
				String attrName = attr.getName();
				if (attrName.startsWith("xmlns:")) {
					if (firstNamespaceDef) {
						firstNamespaceDef = false;
						// Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
						namespacePrefixes = new java.util.HashMap(namespacePrefixes);
					}
					String attrNSPrefix = attrName.substring(6, attrName.length());
					namespacePrefixes.put(attrNSPrefix, attr.getValue());
				}
			}
		}
		org.w3c.dom.NodeList children = node.getChildNodes();
		for (int i = 0, size = children.getLength(); i < size; ++i) {
			org.w3c.dom.Node childNode = children.item(i);
			String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern());
			String childNodeValue = "";
			if (childNode.getFirstChild() != null) {
				childNodeValue = childNode.getFirstChild().getNodeValue();
			}
			if (childNodeName == "schema-type-namespace") {
				_SchemaTypeNamespace = childNodeValue;
			}
			else if (childNodeName == "schema-type-name") {
				_SchemaTypeName = childNodeValue;
			}
			else if (childNodeName == "java-type") {
				_JavaType = childNodeValue;
			}
			else if (childNodeName == "root") {
				if (childNode.getFirstChild() == null)
					_Root = true;
				else
					_Root = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
			}
			else if (childNodeName == "bean") {
				if (childNode.getFirstChild() == null)
					_Bean = true;
				else
					_Bean = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
			}
			else if (childNodeName == "can-be-empty") {
				if (childNode.getFirstChild() == null)
					_CanBeEmpty = true;
				else
					_CanBeEmpty = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
			}
			else {
				// Found extra unrecognized childNode
			}
		}
	}

	public void validate() throws org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException {
		boolean restrictionFailure = false;
		// Validating property schemaTypeNamespace
		// Validating property schemaTypeName
		if (getSchemaTypeName() == null) {
			throw new org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException("getSchemaTypeName() == null", org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException.FailureType.NULL_VALUE, "schemaTypeName", this);	// NOI18N
		}
		// Validating property javaType
		if (getJavaType() == null) {
			throw new org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException("getJavaType() == null", org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException.FailureType.NULL_VALUE, "javaType", this);	// NOI18N
		}
		// Validating property root
		// Validating property bean
		// Validating property canBeEmpty
	}

	public void changePropertyByName(String name, Object value) {
		if (name == null) return;
		name = name.intern();
		if (name == "schemaTypeNamespace")
			setSchemaTypeNamespace((java.lang.String)value);
		else if (name == "schemaTypeName")
			setSchemaTypeName((java.lang.String)value);
		else if (name == "javaType")
			setJavaType((java.lang.String)value);
		else if (name == "root")
			setRoot(((java.lang.Boolean)value).booleanValue());
		else if (name == "bean")
			setBean(((java.lang.Boolean)value).booleanValue());
		else if (name == "canBeEmpty")
			setCanBeEmpty(((java.lang.Boolean)value).booleanValue());
		else
			throw new IllegalArgumentException(name+" is not a valid property name for SchemaTypeMappingType");
	}

	public Object fetchPropertyByName(String name) {
		if (name == "schemaTypeNamespace")
			return getSchemaTypeNamespace();
		if (name == "schemaTypeName")
			return getSchemaTypeName();
		if (name == "javaType")
			return getJavaType();
		if (name == "root")
			return (isRoot() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
		if (name == "bean")
			return (isBean() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
		if (name == "canBeEmpty")
			return (isCanBeEmpty() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
		throw new IllegalArgumentException(name+" is not a valid property name for SchemaTypeMappingType");
	}

	public String nameSelf() {
		return "SchemaTypeMappingType";
	}

	public String nameChild(Object childObj) {
		return nameChild(childObj, false, false);
	}

	/**
	 * @param childObj  The child object to search for
	 * @param returnSchemaName  Whether or not the schema name should be returned or the property name
	 * @return null if not found
	 */
	public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName) {
		return nameChild(childObj, returnConstName, returnSchemaName, false);
	}

	/**
	 * @param childObj  The child object to search for
	 * @param returnSchemaName  Whether or not the schema name should be returned or the property name
	 * @return null if not found
	 */
	public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
		if (childObj instanceof java.lang.String) {
			java.lang.String child = (java.lang.String) childObj;
			if (child == _SchemaTypeNamespace) {
				if (returnConstName) {
					return SCHEMA_TYPE_NAMESPACE;
				} else if (returnSchemaName) {
					return "schema-type-namespace";
				} else if (returnXPathName) {
					return "schema-type-namespace";
				} else {
					return "SchemaTypeNamespace";
				}
			}
			if (child == _SchemaTypeName) {
				if (returnConstName) {
					return SCHEMA_TYPE_NAME;
				} else if (returnSchemaName) {
					return "schema-type-name";
				} else if (returnXPathName) {
					return "schema-type-name";
				} else {
					return "SchemaTypeName";
				}
			}
			if (child == _JavaType) {
				if (returnConstName) {
					return JAVA_TYPE;
				} else if (returnSchemaName) {
					return "java-type";
				} else if (returnXPathName) {
					return "java-type";
				} else {
					return "JavaType";
				}
			}
		}
		if (childObj instanceof java.lang.Boolean) {
			java.lang.Boolean child = (java.lang.Boolean) childObj;
			if (((java.lang.Boolean)child).booleanValue() == _Root) {
				if (returnConstName) {
					return ROOT;
				} else if (returnSchemaName) {
					return "root";
				} else if (returnXPathName) {
					return "root";
				} else {
					return "Root";
				}
			}
			if (((java.lang.Boolean)child).booleanValue() == _Bean) {
				if (returnConstName) {
					return BEAN;
				} else if (returnSchemaName) {
					return "bean";
				} else if (returnXPathName) {
					return "bean";
				} else {
					return "Bean";
				}
			}
			if (((java.lang.Boolean)child).booleanValue() == _CanBeEmpty) {
				if (returnConstName) {
					return CAN_BE_EMPTY;
				} else if (returnSchemaName) {
					return "can-be-empty";
				} else if (returnXPathName) {
					return "can-be-empty";
				} else {
					return "CanBeEmpty";
				}
			}
		}
		return null;
	}

	/**
	 * Return an array of all of the properties that are beans and are set.
	 */
	public org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] childBeans(boolean recursive) {
		java.util.List children = new java.util.LinkedList();
		childBeans(recursive, children);
		org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] result = new org.netbeans.modules.schema2beansdev.beangraph.CommonBean[children.size()];
		return (org.netbeans.modules.schema2beansdev.beangraph.CommonBean[]) children.toArray(result);
	}

	/**
	 * Put all child beans into the beans list.
	 */
	public void childBeans(boolean recursive, java.util.List beans) {
	}

	public boolean equals(Object o) {
		return o instanceof org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType && equals((org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) o);
	}

	public boolean equals(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType inst) {
		if (inst == this) {
			return true;
		}
		if (inst == null) {
			return false;
		}
		if (!(_SchemaTypeNamespace == null ? inst._SchemaTypeNamespace == null : _SchemaTypeNamespace.equals(inst._SchemaTypeNamespace))) {
			return false;
		}
		if (!(_SchemaTypeName == null ? inst._SchemaTypeName == null : _SchemaTypeName.equals(inst._SchemaTypeName))) {
			return false;
		}
		if (!(_JavaType == null ? inst._JavaType == null : _JavaType.equals(inst._JavaType))) {
			return false;
		}
		if (!(_Root == inst._Root)) {
			return false;
		}
		if (!(_Bean == inst._Bean)) {
			return false;
		}
		if (!(_CanBeEmpty == inst._CanBeEmpty)) {
			return false;
		}
		return true;
	}

	public int hashCode() {
		int result = 17;
		result = 37*result + (_SchemaTypeNamespace == null ? 0 : _SchemaTypeNamespace.hashCode());
		result = 37*result + (_SchemaTypeName == null ? 0 : _SchemaTypeName.hashCode());
		result = 37*result + (_JavaType == null ? 0 : _JavaType.hashCode());
		result = 37*result + (_Root ? 0 : 1);
		result = 37*result + (_Bean ? 0 : 1);
		result = 37*result + (_CanBeEmpty ? 0 : 1);
		return result;
	}

	public String toString() {
		java.io.StringWriter sw = new java.io.StringWriter();
		try {
			writeNode(sw);
		} catch (java.io.IOException e) {
			// How can we actually get an IOException on a StringWriter?
			throw new RuntimeException(e);
		}
		return sw.toString();
	}

}


/*
		The following schema file has been used for generation:




  
	
	  
		
	  
	
  

  
	
	  
		Map between schema types and java types.
	  
	
	
	  
	  
		
		  
			The schema type; for instance, "string"
		  
		
	  
	  
		
		  
			The java type; for instance, "java.lang.String", or "int"
		  
		
	  
	  
	  
	  
	
  


*/
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.