Class Name

java.lang.Object
com.bloomberglp.blpapi.Name

public final class Name extends Object
Name objects are used to identify and access the classes which define the schema - SchemaTypeDefinition, SchemaElementDefinition, Constant, ConstantsList. They are also used to access the values in Element objects and Message objects.

The Name class is an efficient substitute for a string when used as a key, providing constant time comparison and ordering operations. Two Name objects constructed from Strings for which equals() would return 'true' will always compare equally.

Name objects should be initialized once and then reused. Creating a Name object from a String involves a search in a container requiring multiple string comparison operations.

Note: Each Name instance refers to an entry in a global static table. Name instances for identical strings will refer to the same data. There is no provision for removing entries from the static table so Name objects should only be used when the set of input strings is bounded.

For example, creating a Name for every possible field name and type in a data model is reasonable (in fact, the API will do this whenever it receives schema information). However, converting sequence numbers on incoming messages to strings and creating a Name from each one of those strings will cause the static table to grow in an unbounded manner and is tantamount to a memory leak.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Name
    Name object representing no actual string.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructed Name.
    Name(String nameString)
    Construct a Name from the specified nameString
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
    Compares this Name object to the specified Object
    static Name
    findName(String nameString)
    Return a reference to a Name object for the specified nameString or null if a Name does not exist.
    static Name
    getName(String nameString)
    Return a reference to a Name object for the specified nameString creating it if it doesn't exist already
    int
    Return a hashcode value for this Name object
    static boolean
    hasName(String nameString)
    Return true if a reference to a Name object exists for the specified nameString
    Return the String this Name object represents

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • NullName

      public static final Name NullName
      Name object representing no actual string.
  • Constructor Details

    • Name

      public Name()
      Default constructed Name. All default constructed Name objects are equivalent to NullName.
    • Name

      public Name(String nameString)
      Construct a Name from the specified nameString

      Constructing a Name from a String is a relatively expensive operation. If a Name will be used repeatedly it is preferable to create it once and re-use the object.

  • Method Details

    • getName

      public static Name getName(String nameString)
      Return a reference to a Name object for the specified nameString creating it if it doesn't exist already
    • findName

      public static Name findName(String nameString)
      Return a reference to a Name object for the specified nameString or null if a Name does not exist.
    • hasName

      public static boolean hasName(String nameString)
      Return true if a reference to a Name object exists for the specified nameString
    • equals

      public boolean equals(Object other)
      Compares this Name object to the specified Object

      The result of the comparison is true if and only if the specified Object is not null, thus Name object is not null, and this Name object contains the same value as the specified Name

      Overrides:
      equals in class Object
      Returns:
      true if the objects are the same false otherwise
    • hashCode

      public int hashCode()
      Return a hashcode value for this Name object
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Return the String this Name object represents
      Overrides:
      toString in class Object