001/** A token that contains an unsized Array number. 002 003 Copyright (c) 2007-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCL5AIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 028 */ 029package ptolemy.data; 030 031import ptolemy.data.type.ArrayType; 032import ptolemy.data.type.Type; 033 034/////////////////////////////////////////////////////////////////// 035//// UnsizedArrayToken 036 037/** 038 A token that represents an array. This token type exists solely so 039 that types can be declared through the parameter mechanism using a 040 token value, since we don't represent types distinctly from tokens. 041 Generally speaking actors should process ArrayTokens, which properly 042 report their length. 043 044 @author Steve Neuendorffer 045 @see ptolemy.data.ArrayToken 046 @version $Id$ 047 @since Ptolemy II 6.1 048 @Pt.ProposedRating Yellow (neuendor) 049 @Pt.AcceptedRating Yellow (neuendor) 050 */ 051public class UnsizedArrayToken extends ArrayToken { 052 053 /** Construct an empty array token with the given element type. 054 * @param elementType A token type. 055 */ 056 public UnsizedArrayToken(Type elementType) { 057 super(elementType); 058 } 059 060 /////////////////////////////////////////////////////////////////// 061 //// public methods //// 062 063 /** Return the type of this token. 064 * @return an unsized array type, having the correct element type. 065 */ 066 @Override 067 public Type getType() { 068 return new ArrayType(getElementType()); 069 } 070 071 /** Return the value of this token as a string that can be parsed 072 * by the expression language to recover a token with the same value. 073 * @return A string beginning with "{" that contains expressions 074 * for every element in the array separated by commas, ending with "}". 075 */ 076 @Override 077 public String toString() { 078 return getType().toString(); 079 } 080}