📄 attributelist.java
字号:
/* * 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 */// $Id: AttributeList.java,v 1.2 2000/09/05 13:30:30 festor Exp $// $Source: /local/resedas/CVS-Repository/CmisJavaApi/src/fr/dyade/cmis/api/types/AttributeList.java,v $//// Todo//package fr.dyade.cmis.api.types;// Java related Packagesimport java.util.Vector;import java.util.Enumeration;import java.util.NoSuchElementException;/** ASN1 type for Attribute list * In X711 this type is directly coded as an IMPLICIT SET of Attribute. * * The implementation uses Java Vector. * TODO: may be an hash table, using AttributeId as key would be a better implementation... * for a direct use in Managed Object instances agent implementation.... * * @version $Id: AttributeList.java,v 1.2 2000/09/05 13:30:30 festor Exp $ */public class AttributeList extends CMISType { /** Default constructor. */ public AttributeList() { } /** * Creates a new instance of AttibuteList, with pAttribute as first element. * @param pAttribute The first <code>Attribute</code> of the <code>AttributeList</code> */ public AttributeList( Attribute pAttribute ) { super(); fElts.addElement( pAttribute ); } /** * Creates a new instance of AttibuteList, with <dotted notation, value> as first element. * @param pDottedFormOID the iod for the first element * @param pValue the value for the first element */ public AttributeList( String pDottedFormOID, Value pValue ) { this(new Attribute(pDottedFormOID, pValue)); } /** * Adds an <code>Attribute</code> to the <code>AttributeList</code> * @param pAttribute The <code>Attribute</code> to add to the <code>AttributeList</code> */ public final void add( Attribute pAttribute ) { fElts.addElement(pAttribute); } /** Adds an attribute to the list form AttributeId dotted notation and value. */ public final void add(String pDottedFormOID, Value pValue) { add(new Attribute(pDottedFormOID, pValue)); } /** Adds an attribute to the list * This is a convenient method to add a new attribute from its id ans value. * @param pAID the attribute id for the attribute to be added * @param pValue the value for the attribute to be added */ public final void add( AttributeId pAID, Value pValue ) { add(new Attribute(pAID, pValue)); } /** List elements, via java enumeration. * This method gives access to Attribute elements of the list, via java enumeration. * @return The enumeration of the attribute list elements. * <p>NOTE: Use cast to <code>{@link Attribute}</code> * when calling the <code>java.lang.util.Enumeration.nextElement()</code> * method of the result. */ public Enumeration getElts() { return fElts.elements(); } /** Get the first Attribute. * This method returns the first Attribute in the list. * @return an Attribute (ava). * @throws java.util.NoSuchElementException if the list is empty * NOTE: Usually shipped attribute list returns CMIS reponse are not empty * so we adopte an exception to signal empty list. */ public final Attribute getFirst() throws NoSuchElementException { return (Attribute)fElts.firstElement(); } /** Get the value associated to an attribute id. * @param ai the attribute id to look up in the list * @return the value associated to parameter attribute id. * @throws NoSuchElementException when the parameter is not present in the list * */ public final Value getValue( AttributeId ai ) throws NoSuchElementException { return getAttribute(ai).getValue(); } /** Get the attribute (aid+value) associated to an attribute id. * @param ai the attribute id to look up in the list * @return the attribute associated to parameter attribute id. * @throws NoSuchElementException when the parameter is not present in the list * <p>The use of this <code>RuntimeException</code> is probably not a good idea, because the * user <b>is not obliged</b> to catch lookup failure is this case. */ public final Attribute getAttribute( AttributeId ai ) throws NoSuchElementException { for (Enumeration e=getElts(); e.hasMoreElements();) { Attribute attr=(Attribute)e.nextElement(); if (attr.isOfId(ai)) { return attr; } } throw new NoSuchElementException(); } /** * Returns a <code>String</code> representation of the <code>AttributeList</code> * @return A <code>String</code> for the <code>AttributeList</code> */ public String toString() { String lResult = "["; for (Enumeration e=fElts.elements(); e.hasMoreElements() ;) { lResult += e.nextElement().toString() + "\n"; } lResult+= "]"; return lResult; } /** Actual AVA list. * @see Attribute * TODO: find out average AttributeList length. - See for an application property * associated to this size. */ private Vector fElts = new Vector(30);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -