Re: Name format limitations ...

Hi Don,

> Some of our user data comes in tagged with human readable names (eg.,
> with spaces) which we'd like to maintain as is, but which causes
> problems for RealType/ScalarType objects when they hit validateName().
> I guess the question is why are there "reserved" characters for the
> RealType/ScalarType name String's, or alternatively, what would break if
> a name were just any String?
>
> Would this work and are there hidden effects???

This wouldn't work: it would break the code that parses more
general MathType expressions like:

  (time -> ((x, y, z) -> (t, p)))

I recommend using underscore "_" in place of spaces in RealType
names. I really dislike the use of spaces in Windows file names,
because of all the trouble they cause with programs that need
file names as arguments.

I believe VisAD includes methods that let you alias RealType
names to other strings that do include special characters.
Perhaps someone who uses these methods can fill you in.

Bill

>   /**
>    * Throw a <CODE>TypeException</CODE> if the name is invalid.
>    *
>    * @param name Name to check.
>    * @param type Type used in exception message.
>    *
>    * @exception TypeException If there is a problem with the name.
>    */
>   public static synchronized void validateName(String name, String type)
>     throws TypeException
>   {
>     if (name == null) {
>       throw new TypeException("ScalarType: " + type + " cannot be
> null");
>     }
> //    if (name.indexOf(".") > -1 ||
> //        name.indexOf(" ") > -1 ||
> //        name.indexOf("(") > -1 ||
> //        name.indexOf(")") > -1) {
> //      throw new TypeException("ScalarType: " + type + " cannot contain
> " +
> //                              "space . ( or ) " + name);
> //    }
>     if (getScalarTypeByName(name) != null) {
>       throw new TypeException("ScalarType: " + type + " already used");
>     }
>     if (Translations.containsKey(name)) {
>       throw new TypeException("ScalarType: " + type + " already used" +
>                             " as an alias");
>     }
>   }
>
> thanks...  dlf
>


  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: