001/* Matrix token with no element type. 002 003 Copyright (c) 1997-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 DISCLAIMS 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.expr; 030 031import ptolemy.data.MatrixToken; 032import ptolemy.data.Token; 033import ptolemy.data.type.BaseType; 034import ptolemy.data.type.Type; 035 036/////////////////////////////////////////////////////////////////// 037//// ConcreteMatrixToken 038 039/** 040 A token that represents an empty matrix, with no element type. 041 This is instantiated by the Constants class with name "matrix". 042 043 @author Edward A. Lee 044 @version $Id$ 045 @since Ptolemy II 2.0 046 @Pt.ProposedRating Yellow (yuhong) 047 @Pt.AcceptedRating Yellow (wbwu) 048 @see Constants 049 */ 050public class ConcreteMatrixToken extends MatrixToken { 051 /////////////////////////////////////////////////////////////////// 052 //// public methods //// 053 054 /** Return the number of columns of the contained matrix. 055 * @return Zero. 056 */ 057 @Override 058 public int getColumnCount() { 059 return 0; 060 } 061 062 /** Throw an ArrayIndexOutOfBoundsException. 063 * @param row The row index of the desired element. 064 * @param column The column index of the desired element. 065 * @return An exception. 066 * @exception ArrayIndexOutOfBoundsException Always thrown. 067 */ 068 @Override 069 public Token getElementAsToken(int row, int column) 070 throws ArrayIndexOutOfBoundsException { 071 throw new ArrayIndexOutOfBoundsException("Empty matrix."); 072 } 073 074 /** Return the Type of the tokens contained in this matrix token. 075 * @return A Type. 076 */ 077 @Override 078 public Type getElementType() { 079 throw new ArrayIndexOutOfBoundsException("Empty matrix."); 080 } 081 082 /** Return the number of rows of the contained matrix. 083 * @return Zero. 084 */ 085 @Override 086 public int getRowCount() { 087 return 0; 088 } 089 090 /** Return the type of this token. 091 * @return BaseType.MATRIX. 092 */ 093 @Override 094 public Type getType() { 095 return BaseType.MATRIX; 096 } 097}