composedvalue.java

来自「CmisJavaApi」· Java 代码 · 共 177 行

JAVA
177
字号
/* * The contents of this file are subject to the Dyade Public License,  * as defined by the file DYADE_PUBLIC_LICENSE.TXT * * You may not use this file except in compliance with the License. You may * obtain a copy of the License on the Dyade web site (www.dyade.fr). * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific terms governing rights and limitations under the License. * * The Original Code is CmisJava API, including the java package  * fr.dyade.cmis, released September 5, 2000. * * The Initial Developer of the Original Code is Dyade. The Original Code and * portions created by Dyade are Copyright Bull and Copyright INRIA.  * All Rights Reserved. *//*      Copyright 1996-2000 by Institut National de Recherche en Informatique  *                             et en Automatique (INRIA) *          All rights reserved.  See COPYRIGHT in top-level directory. * *      Authors: Laurent Andrey, Eric Dillon, Olivier Festor *///---------------------------------------------------------------------------////  CVS Info//---------------------------------------------------------------------------//////  $Id: ComposedValue.java,v 1.3 2000/09/05 13:30:35 festor Exp $//  $Source: /local/resedas/CVS-Repository/CmisJavaApi/src/fr/dyade/cmis/api/types/ComposedValue.java,v $//---------------------------------------------------------------------------////  Todo//---------------------------------------------------------------------------////  Find ASN1 spec (which one) corresponding to this java class...package fr.dyade.cmis.api.types;// Java related Packagesimport java.util.Vector;import java.util.Enumeration;/**  *  Java representation for an ASN.1 Sequence/Set/"List" datatype.  *  <p>  *  We provide 3 static constructors to build each composed datatype:  *  <menu>  *     <li> SEQ_VALUE(..), for ASN.1 Sequence,  *     <li> SET_VALUE(..), for ASN.1 Set,  *     <li> LIST_VALUE(..).  *  </menu>  *  Once the composed type has been instanciated with the first <code>Value</code>, you can use the  *  <code>add(..)</code> method to add values to the composed datatype.  *  <p>  * To test which composed data type has a <code>ComposedValue</code> instance, the user may call the   * <code>getComposedType()</code> method. This will return one of the following values:  * <menu>  *    <li> SEQ_VALUE_TYPE,  *    <li> SET_VALUE_TYPE,  *    <li> LIST_VALUE_TYPE,  * </menu>  */public class ComposedValue  extends Value {      // Those tag are Open Master c-api ones...      private static final short SEQ_VALUE_TYPE = 21;      private static final short SET_VALUE_TYPE = 22;      private static final short LIST_VALUE_TYPE = 23;        /** Private constructor.	* Dedicated to public static factory and JNI level mappers.	*/      private ComposedValue(Value pValue, short pType) {	 super(COMPOSED_VALUE);	 fValues.addElement(pValue);	 fType = pType;      }        /** Private contructor for empty Composed value.        * Dedicated to public static factory and JNI level mappers.       */       private ComposedValue(short pType) {	  super(COMPOSED_VALUE);	  fType = pType;       }      /** Creates a new empty ANS1 SET-OF (SEQ_VALUE)        */      public static ComposedValue SEQ_VALUE()  {	 return new ComposedValue(SEQ_VALUE_TYPE);      }      /**	* Creates a new instance for an ASN1 SEQUENCE (SEQ_VALUE).	* @param pValue The first <code>Value</code> of this sequence.	*/      public static ComposedValue SEQ_VALUE(Value pValue)  {	 return new ComposedValue(pValue, SEQ_VALUE_TYPE);      }      /** Creates a new empty ASN1 SET-OF (SET_VALUE)       */      public static ComposedValue SET_VALUE(){	 return new ComposedValue(SET_VALUE_TYPE);      }        /**	* Creates a new instance of an ASN1 SET-OF (SET_VALUE).	* @param pValue The first <code>Value</code> of this set.	*/      public static ComposedValue SET_VALUE(Value pValue){	 return new ComposedValue(pValue, SET_VALUE_TYPE);      }        /** Creates a new empty SEQUENCE OF (LIST_VALUE)       */      public static ComposedValue LIST_VALUE(){	 return new ComposedValue(LIST_VALUE_TYPE);      }      /**	* Creates a new instance of a an SEQUENCE OF (LIST_VALUE).	* @param pValue The first <code>Value</code> of this <code>ComposedValue</code>.	*/      public static ComposedValue LIST_VALUE(Value pValue){	 return new ComposedValue(pValue, LIST_VALUE_TYPE);      }        /**	* Adds a <code>Value</code> to the current <code>ComposedValue</code> instance.	* It is a tail insertion. This implicit order is  meaningless for SET  (unordered) but quite 	* significant for SEQUENCE and LIST. 	* <b>Beware</b>: No check about type coherency is made for LIST and SET.	* @param pValue The <code>Value</code> to add to the composed value.	*/      public void add(Value pValue){	 fValues.addElement(pValue);      }      /**	* Elements of a ComposedValue.	* @return An <code>Enumeration</code> object to access every value elements.	*/      public Enumeration getValues(){	 return fValues.elements();      }            /**	* Returns the composed data type of the <code>ComposedValue</code> instance.	* @return composed data type	*/      public short getComposedType(){	 return fType;      }      public String toString(){	 String res;	 switch(fType) {	    case SEQ_VALUE_TYPE: 	       res="[SEQUENCE ";	       break;	    case SET_VALUE_TYPE:	       res="[SETOF ";	       break;	    case LIST_VALUE_TYPE:	       res="[SEQUENCEOF ";	       break;	    default:	       res="[BAD_COMPOSE_TYPE_CODE ";	       break;	 }	 for (Enumeration e=fValues.elements(); e.hasMoreElements(); ) {	    res += e.nextElement();	    if (e.hasMoreElements()) {	       res+="; ";	    }	 }	 return res + "]";      }      private short fType;      private Vector fValues = new Vector();} // ComposedValue

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?