001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.migration.model20.other;
023:
024: import java.io.Serializable;
025: import java.util.List;
026:
027: /**
028: * A read only interface used to retrieve data. It represents both for mono value and multi values. It must implement
029: * equals and hashCode.
030: * <p/>
031: * The semantics :
032: * <p/>
033: * | Storage | mono | multi | | xxx | xxx | [xxx] | | null | null | [null] |
034: * -------------------------------- | [] | null | [] | | [null,..] | null | [null,..] | | ["1",..] | "1"
035: * | ["1",..] |
036: *
037: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
038: * @version $Revision: 8784 $
039: */
040: public interface Value extends Serializable {
041:
042: // ***********************
043: // * Mono valued methods *
044: // ***********************
045:
046: /** Return true if the value is null. */
047: boolean isNull();
048:
049: /** Return the value as a string. */
050: String asString();
051:
052: /**
053: * Return the value as an int.
054: *
055: * @throws NullConversionException if one of the values is null
056: * @throws FormatConversionException if one of the values cannot be converted
057: */
058: int asInt() throws NullConversionException,
059: FormatConversionException;
060:
061: /**
062: * Return the value as a boolean.
063: *
064: * @throws NullConversionException if one of the values is null
065: * @throws FormatConversionException if one of the values cannot be converted
066: */
067: boolean asBoolean() throws NullConversionException,
068: FormatConversionException;
069:
070: /** Return the value. */
071: Object asObject();
072:
073: // ************************
074: // * Multi valued methods *
075: // ************************
076:
077: /** Return true if it contains more than one value. */
078: boolean isMultiValued();
079:
080: /** Return the values as an array of string. */
081: String[] asStringArray();
082:
083: /**
084: * Return the values as an array of int.
085: *
086: * @throws NullConversionException if one of the values is null
087: * @throws FormatConversionException if one of the values cannot be converted
088: */
089: int[] asIntArray() throws NullConversionException,
090: FormatConversionException;
091:
092: /**
093: * Return the values as an array of boolean.
094: *
095: * @throws NullConversionException if one of the values is null
096: * @throws FormatConversionException if one of the values cannot be converted
097: */
098: boolean[] asBooleanArray() throws NullConversionException,
099: FormatConversionException;
100:
101: /** Return the values as an array of converted object. */
102: Object[] asObjectArray();
103:
104: /** Return the values as an immutable collection of converted object or null. */
105: List asObjectList();
106: }
|