001/* Assistance methods for token classes. 002 003 Copyright (c) 1998-2013 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 */ 028package ptolemy.data; 029 030import java.text.DecimalFormat; 031import java.text.DecimalFormatSymbols; 032 033/////////////////////////////////////////////////////////////////// 034//// TokenUtilities 035 036/** 037 Various methods and fields that are used from within the various token 038 classes. This code is factored out here into a separate class to allow 039 for simple use by the code generator. 040 041 @author Steve Neuendorffer 042 @version $Id$ 043 @since Ptolemy II 2.1 044 @Pt.ProposedRating Green (neuendor) 045 @Pt.AcceptedRating Green (cxh) 046 */ 047public class TokenUtilities { 048 /////////////////////////////////////////////////////////////////// 049 //// public fields //// 050 // Note that these fields are public, since they are sometimes 051 // useful to have in other places, like the code generator. 052 053 /** The format that is used to print floating point numbers that 054 * are not very large, or very small. The number of fractional 055 * digits here is determined by the place at which common 056 * numbers, such as one half, will get rounded to display nicely. 057 */ 058 public static final DecimalFormat regularFormat = new DecimalFormat( 059 "####0.0############", 060 new DecimalFormatSymbols(java.util.Locale.US)); 061 062 // Note: This used to be new DecimalFormat("0.0############E0##"), 063 // but compiling with gcj resulted in the following error: 064 // 'Exception in thread "main" class 065 // java.lang.ExceptionInInitializerError: 066 // java.lang.IllegalArgumentException: digit mark following zero 067 // in exponent - index: 17' 068 069 // See ptII/ptolemy/data/test/TokenUtilities.tcl for why we 070 // need that many # in the format. 071 072 /** The format that is used to print floating point numbers that 073 * are very large, or very small. 074 */ 075 public static final DecimalFormat exponentialFormat = new DecimalFormat( 076 "0.0##############E0", 077 new DecimalFormatSymbols(java.util.Locale.US)); 078}