text: /*
   * Jsonix is a JavaScript library which allows you to convert between XML
   * and JavaScript object structures.
   *
   * Copyright (c) 2010 - 2014, Alexey Valikov, Highsource.org
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   *     * Redistributions of source code must retain the above copyright
   *       notice, this list of conditions and the following disclaimer.
   *     * 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.
   *     * Neither the name of the Alexey Valikov nor the
   *       names of contributors may be used to endorse or promote products
   *       derived from this software without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
   * ANY EXPRESS 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 ALEXEY VALIKOV 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.
   */
  
  Jsonix.Model.AttributePropertyInfo = Jsonix.Class(Jsonix.Model.SingleTypePropertyInfo, {
  	attributeName : null,
  	initialize : function(options) {
  		Jsonix.Util.Ensure.ensureObject(options);
  		Jsonix.Model.SingleTypePropertyInfo.prototype.initialize.apply(this, [ options ]);
  		// TODO Ensure correct argument
  		if (Jsonix.Util.Type.isObject(options.attributeName)) {
  			Jsonix.Util.Ensure.ensureString(options.attributeName.localPart, 'Attribute name must contain a string property [localPart].');
  			this.attributeName = Jsonix.XML.QName.fromObject(options.attributeName);
  		} else if (Jsonix.Util.Type.isString(options.attributeName)) {
  			this.attributeName = new Jsonix.XML.QName(this.defaultAttributeNamespaceURI, options.attributeName);
  		} else {
  			this.attributeName = new Jsonix.XML.QName(this.defaultAttributeNamespaceURI, this.name);
  		}
  	},
  	unmarshal : function(context, scope, input) {
  		var attributeCount = input.getAttributeCount();
  		var result = null;
  		for ( var index = 0; index < attributeCount; index++) {
  			var attributeNameKey = input.getAttributeNameKey(index);
  			if (this.attributeName.key === attributeNameKey) {
  				var attributeValue = input.getAttributeValue(index);
  				if (Jsonix.Util.Type.isString(attributeValue)) {
  					result = this.unmarshalValue(context, scope, input, attributeValue);
  				}
  			}
  		}
  		return result;
  	},
  	marshal : function(context, scope, value, output) {
  		if (Jsonix.Util.Type.exists(value)) {
  			output.writeAttribute(this.attributeName, this.print(context, scope, value));
  		}
  
  	},
  	buildStructure : function(context, structure) {
  		Jsonix.Util.Ensure.ensureObject(structure);
  		Jsonix.Util.Ensure.ensureObject(structure.attributes);
  		var key = this.attributeName.key;
  		// if (Jsonix.Util.Type.exists(structure.attributes[key])) {
  		// // TODO better exception
  		// throw new Error("The structure already defines an attribute for the key
  		// ["
  		// + key + "].");
  		// } else
  		// {
  		structure.attributes[key] = this;
  		// }
  	},
  	CLASS_NAME : 'Jsonix.Model.AttributePropertyInfo'
  });
  