All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.mdl.IAtomic Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

// @(#) $Id: IAtomic.java 2089 2007-11-28 13:56:13Z s3460 $
package at.spardat.xma.mdl;

import java.math.BigDecimal;
import java.util.Date;

import at.spardat.enterprise.fmt.IFmt;

/**
 * Classes implementing IAtomic are the types used in XMA to represent atomic values 
 * both at the client and at the server side.
 * To facilitate transport over the network, this
 * type has a type (from {@link at.spardat.enterprise.util.Types Types}) and
 * a String encoded atomic value.
 * 
 * The typed values which are held by this are string encoded.
 * The encodings are as follows:
 * 
 * TYPE          ENCODING
 * ---------------------------------------------------------------------------------------
 * T_BOOLEAN     "J" or "N"
 * T_STRING      the string itself
 * T_BCD         canonic string format of ABcd, see ABcd.toString(). Example: -12000.32
 * T_DATE        canonic string format of ADate yyyyMMdd, see ADate.toString()
 * T_TIMESTAMP   encoding as defined in {@link at.spardat.enterprise.util.TimeStampUtil}.
 * T_DOM         key of the domain value, see {@link at.spardat.xma.datasource.ADomX}.
 * 
* * An Atom may be created from and converted to the most JDK supplied types. The following table * lists the conversions: *
 * TYPE          may be converted to, may be constructed from
 * ---------------------------------------------------------------------------------------
 * T_BOOLEAN     Boolean
 * T_STRING      String
 * T_BCD         Double, Integer
 * T_DATE        java.util.Date
 * T_TIMESTAMP   java.sql.Timestamp
 * 
* * @author YSD, 05.06.2003 09:20:54 */ public interface IAtomic { /** * Returns true if this Atom holds a value. * * @return true if this has a non empty value. */ public abstract boolean hasValue(); /** * Returns the type constant. * * @return the type constant. */ public abstract byte getType(); /** * Maps this Atom to string representation using a IFmt object. * The provided formatter is only used if it is type compatible * with the type of this Atom. Otherwise, or if formatter is * null, the internal String encoding is returned. * * @param formatter the IFmt formatter. May be null. * @return non null String. */ public abstract String toString(IFmt formatter); /** * Returns a String representing the value of this. Depending on the type of this, the following * formats are returned: *
     * T_BOOLEAN     "J" or "N"
     * T_STRING      the string itself
     * T_BCD         -12000.32
     * T_DATE        yyyyMMdd
     *               example: 20001231, the last day in the year 2000
     * T_TIMESTAMP   yyyyMMdd HH:mm:ss.SSS z
     *               example: 20001231 23:59:59.999 CET denoting the last millisecond in the year 2000, central european time.
     * T_DOM         key of the domain value
     * 
* The empty string is returned if this does not store a value. * * @return the above defined encodings or the empty string if this is unvalued (!hasValue()). */ public String toString(); /** * Extracts a double from this. Returns 0.0 if getType() is not equal to T_BCD or !hasValue(). * * @return the double value of this * @exception NumberFormatException if this does not fit into a double. */ public abstract double toDouble(); /** * Extracts a float from this. Returns 0.0 if getType() is not equal to T_BCD or !hasValue(). * * @return the float value of this * @exception NumberFormatException if this does not fit into a float. */ public abstract float toFloat (); /** * Returns the value of this as int. Requires that this is either empty or contains an * integer T_BCD value. If !hasValue() * or the type of this is not T_BCD, zero is returned. * * @return the contained integer * @exception NumberFormatException if this does not fit into an int */ public abstract int toInt(); /** * Returns the value of this as long. Requires that this is either empty or contains an * T_BCD value. If !hasValue() * or the type of this is not T_BCD, zero is returned. * * @return the contained value as long * @exception NumberFormatException if this does not fit into an long */ public abstract long toLong(); /** * Returns the value of this as byte. Requires that this is either empty or contains * an T_BCD value. If !hasValue() * or the type of this is not T_BCD, zero is returned. * * @return the contained value as long * @exception NumberFormatException if this does not fit into an byte */ public abstract byte toByte(); /** * Returns the value of this as short. Requires that this is either empty or contains * an T_BCD value. If !hasValue() * or the type of this is not T_BCD, zero is returned. * * @return the contained value as long * @exception NumberFormatException if this does not fit into a short */ public abstract short toShort(); /** * Returns a newly constructed java.util.Date object representing the value of this. * * @return null if the type is not equal to T_DATE or T_TIMESTAMP or !hasValue(). */ public abstract Date toDate(); /** * Returns true if getType() equals T_BOOLEAN and the stored value equals TRUE. If * there is no value stored or the stored value is not TRUE, false is returned. * * @return boolean indicating the value in this. */ public abstract boolean isTrue(); /** * If the type of this is T_BCD, the numeric value is returned as a BigDecimal. * If the type is another than T_BCD or !hasValue() is true, then null * is returned. */ public abstract BigDecimal toBigDecimal (); /** * Returns the String encoded value of this. Returns the empty String if !hasValue().

*/ public abstract String getEncodedValue (); /** * Returns the value of this as Byte or null if !hasValue() or the * type is not T_BCD. * * @exception RuntimeException if the value stored in this does not fit into a Byte. */ public Byte toBYTE (); /** * Returns the value of this as Short or null if !hasValue() or the * type is not T_BCD. * * @exception RuntimeException if the value stored in this does not fit into a Short. */ public Short toSHORT(); /** * Returns the value of this as Integer or null if !hasValue() or the * type is not T_BCD. * * @exception RuntimeException if the value stored in this does not fit into a Integer. */ public Integer toINTEGER(); /** * Returns the value of this as Long or null if !hasValue() or the * type is not T_BCD. * * @exception RuntimeException if the value stored in this does not fit into a Long. */ public Long toLONG(); /** * Returns the value of this as Float or null if !hasValue() or the * type is not T_BCD. */ public Float toFLOAT(); /** * Returns the value of this as Double or null if !hasValue() or the * type is not T_BCD. */ public Double toDOUBLE(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy