?? stringattributes.java
字號:
/*Copyright (c) 2004-2005, Dennis M. SosnoskiAll 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 JiBX nor the names of its 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" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FORANY 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 ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/package org.jibx.binding.model;import java.lang.reflect.Constructor;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;import org.jibx.binding.util.StringArray;import org.jibx.runtime.IMarshallingContext;import org.jibx.runtime.IUnmarshallingContext;import org.jibx.runtime.JiBXException;import org.jibx.runtime.QName;/** * Model component for <i>string</i> attribute group in binding definition. * * @author Dennis M. Sosnoski * @version 1.0 */ public class StringAttributes extends AttributeBase{ /** Enumeration of allowed attribute names */ public static final StringArray s_allowedAttributes = new StringArray(new String[] { "default", "deserializer", "serializer" }); // TODO: add "format" for 2.0 // // Constants and such related to code generation. // signature variants allowed for serializer private static final String[] SERIALIZER_SIGNATURE_VARIANTS = { "Lorg/jibx/runtime/IMarshallingContext;", "Ljava/lang/Object;", "" }; // signatures allowed for deserializer private static final String[] DESERIALIZER_SIGNATURES = { "(Ljava/lang/String;Lorg/jibx/runtime/IUnmarshallingContext;)", "(Ljava/lang/String;Ljava/lang/Object;)", "(Ljava/lang/String;)" }; // signature required for constructor from string private static final String STRING_CONSTRUCTOR_SIGNATURE = "(Ljava/lang/String;)"; // classes of arguments to constructor or deserializer private static final Class[] STRING_CONSTRUCTOR_ARGUMENT_CLASSES = { java.lang.String.class }; // // Instance data. /** Referenced format name. */ private String m_formatName; /** Format qualified name. */ private QName m_formatQName; /** Default value text. */ private String m_defaultText; /** Serializer fully qualified class and method name. */ private String m_serializerName; /** Deserializer fully qualified class and method name. */ private String m_deserializerName; /** Base format for conversions. */ private FormatElement m_baseFormat; /** Value type class. */ private IClass m_typeClass; /** Default value object. */ private Object m_default; /** Serializer method (or toString equivalent) information. */ private IClassItem m_serializerItem; /** Deserializer method (or constructor from string) information. */ private IClassItem m_deserializerItem; /** * Default constructor. */ public StringAttributes() {} /** * Set value type. This needs to be set by the owning element prior to * validation. Even though the type is an important part of the string * information, it's treated as a separate item of information because it * needs to be used as part of the property attributes. * * @param type value type */ public void setType(IClass type) { m_typeClass = type; } /** * Get value type. * * @return value type */ public IClass getType() { return m_typeClass; } /** * Get base format name. * * @return referenced base format */ public String getFormatName() { return m_formatName; } /** * Set base format name. * * @param name referenced base format */ public void setFormatName(String name) { m_formatName = name; m_formatQName = (name == null) ? null : new QName(name); } /** * Get format qualified name. * * @return format qualified name (<code>null</code> if none) */ public QName getFormatQName() { return m_formatQName; } /** * Set format qualified name. This method changes the label value to match * the qualified name. * * @return format qualified name (<code>null</code> if none) */ public void setFormatQName(QName qname) { m_formatQName = qname; m_formatName = (qname == null) ? null : qname.toString(); } /** * Get default value text. * * @return default value text */ public String getDefaultText() { return m_defaultText; } /** * Get default value. This method is only usable after a * call to {@link #validate}. * * @return default value object */ public Object getDefault() { return m_default; } /** * Set default value text. * * @param value default value text */ public void setDefaultText(String value) { m_defaultText = value; } /** * Get serializer name. * * @return fully qualified class and method name for serializer (or * <code>null</code> if none) */ public String getSerializerName() { return m_serializerName; } /** * Get serializer method information. This method is only usable after a * call to {@link #validate}. * * @return serializer information (or <code>null</code> if none) */ public IClassItem getSerializer() { return m_serializerItem; } /** * Set serializer method name. * * @param fully qualified class and method name for serializer */ public void setSerializerName(String name) { m_serializerName = name; } /** * Get deserializer name. * * @return fully qualified class and method name for deserializer (or * <code>null</code> if none) */ public String getDeserializerName() { return m_deserializerName; } /** * Get deserializer method information. This method is only usable after a * call to {@link #validate}. * * @return deserializer information (or <code>null</code> if none) */ public IClassItem getDeserializer() { return m_deserializerItem; } /** * Set deserializer method name. * * @param fully qualified class and method name for deserializer */ public void setDeserializerName(String name) { m_deserializerName = name; } /**
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -