001: /*-
002: * See the file LICENSE for redistribution information.
003: *
004: * Copyright (c) 2002,2008 Oracle. All rights reserved.
005: *
006: * $Id: RawType.java,v 1.10.2.2 2008/01/07 15:14:21 cwl Exp $
007: */
008:
009: package com.sleepycat.persist.raw;
010:
011: import java.util.List;
012: import java.util.Map;
013:
014: import com.sleepycat.persist.model.Entity;
015: import com.sleepycat.persist.model.Persistent;
016:
017: /**
018: * The type definition for a simple or complex persistent type, or an array
019: * of persistent types.
020: *
021: * <p>{@code RawType} objects are thread-safe. Multiple threads may safely
022: * call the methods of a shared {@code RawType} object.</p>
023: *
024: * @author Mark Hayes
025: */
026: public interface RawType {
027:
028: /**
029: * Returns the class name for this type in the format specified by {@link
030: * Class#getName}.
031: *
032: * <p>If this class currently exists (has not been removed or renamed) then
033: * the class name may be passed to {@link Class#forName} to get the current
034: * {@link Class} object. However, if this raw type is not the current
035: * version of the class, this type information may differ from that of the
036: * current {@link Class}.</p>
037: */
038: String getClassName();
039:
040: /**
041: * Returns the class version for this type. For simple types, zero is
042: * always returned.
043: *
044: * @see Entity#version
045: * @see Persistent#version
046: */
047: int getVersion();
048:
049: /**
050: * Returns whether this is a {@link <a
051: * href="../model/Entity.html#simpleTypes">simple type</a>}: primitive,
052: * primitive wrapper, BigInteger, String or Date.
053: * <!--
054: * primitive wrapper, BigInteger, BigDecimal, String or Date.
055: * -->
056: *
057: * <p>If true is returned, {@link #isPrimitive} can be called for more
058: * information, and a raw value of this type is represented as a simple
059: * type object (not as a {@link RawObject}).</p>
060: *
061: * <p>If false is returned, this is a complex type, an array type (see
062: * {@link #isArray}), or an enum type, and a raw value of this type is
063: * represented as a {@link RawObject}.</p>
064: */
065: boolean isSimple();
066:
067: /**
068: * Returns whether this type is a Java primitive: char, byte, short, int,
069: * long, float or double.
070: *
071: * <p>If true is returned, this is also a simple type. In other words,
072: * primitive types are a subset of simple types.</p>
073: *
074: * <p>If true is returned, a raw value of this type is represented as a
075: * non-null instance of the primitive type's wrapper class. For example,
076: * an <code>int</code> raw value is represented as an
077: * <code>Integer</code>.</p>
078: */
079: boolean isPrimitive();
080:
081: /**
082: * Returns whether this is an enum type.
083: *
084: * <p>If true is returned, a value of this type is a {@link RawObject} and
085: * the enum constant String is available via {@link RawObject#getEnum}.</p>
086: *
087: * <p>If false is returned, then this is a complex type, an array type (see
088: * {@link #isArray}), or a simple type (see {@link #isSimple}).</p>
089: */
090: boolean isEnum();
091:
092: /**
093: * Returns an unmodifiable list of the names of the enum instances, or null
094: * if this is not an enum type.
095: */
096: List<String> getEnumConstants();
097:
098: /**
099: * Returns whether this is an array type. Raw value arrays are represented
100: * as {@link RawObject} instances.
101: *
102: * <p>If true is returned, the array component type is returned by {@link
103: * #getComponentType} and the number of array dimensions is returned by
104: * {@link #getDimensions}.</p>
105: *
106: * <p>If false is returned, then this is a complex type, an enum type (see
107: * {@link #isEnum}), or a simple type (see {@link #isSimple}).</p>
108: */
109: boolean isArray();
110:
111: /**
112: * Returns the number of array dimensions, or zero if this is not an array
113: * type.
114: */
115: int getDimensions();
116:
117: /**
118: * Returns the array component type, or null if this is not an array type.
119: */
120: RawType getComponentType();
121:
122: /**
123: * Returns a map of field name to raw field for each non-static
124: * non-transient field declared in this class, or null if this is not a
125: * complex type (in other words, this is a simple type or an array type).
126: */
127: Map<String, RawField> getFields();
128:
129: /**
130: * Returns the type of the superclass, or null if the superclass is Object
131: * or this is not a complex type (in other words, this is a simple type or
132: * an array type).
133: */
134: RawType getSuperType();
135: }
|