Java Annotation Indexer 1.0.0.Final-redhat-1

org.jboss.jandex
Class DotName

java.lang.Object
  extended by org.jboss.jandex.DotName
All Implemented Interfaces:
Comparable<DotName>

public final class DotName
extends Object
implements Comparable<DotName>

A DotName represents a dot separated name, typically a Java package or a Java class. It has two possible variants. A simple wrapper based variant allows for fast construction (it simply wraps the specified name string). Whereas, a componentized variant represents one or more String components that when combined with a dot character, assemble the full name. The intention of the componentized variant is that the String components can be reused to offer memory efficiency. This reuse is common in Java where packages and classes follow a tree structure.

Both the simple and componentized variants are considered semantically equivalent if they refer to the same logical name. More specifically the equals and hashCode methods return the same values for the same semantic name regardless of the variant used. Which variant to use when depends on the specific performance and overhead objectives of the specific use pattern.

Simple names are cheap to construct (just a an additional wrapper object), so are ideal for temporary use, like looking for an entry in a Map. Componentized names however require that they be split in advance, and so require some additional time to construct. However the memory benefits of reusing component strings make them desirable when stored in a longer term area such as in a Java data structure.

Author:
Jason T. Greene

Method Summary
 int compareTo(DotName other)
           
static DotName createComponentized(DotName prefix, String localName)
          Constructs a componentized DotName.
static DotName createSimple(String name)
          Constructs a simple DotName which stores the string in it's entirety.
 boolean equals(Object o)
           
 int hashCode()
           
 boolean isComponentized()
          Returns whether this DotName is a componentized variant.
 String local()
          Returns the local portion of this DotName.
 DotName prefix()
          Returns the parent prefix for this DotName or null if there is none.
 String toString()
          Returns the regular fully qualifier class name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

createSimple

public static DotName createSimple(String name)
Constructs a simple DotName which stores the string in it's entirety. This variant is ideal for temporary usage, such as looking up an entry in a Map.

Parameters:
name - A fully qualified non-null name (with dots)
Returns:
a simple DotName that wraps name

createComponentized

public static DotName createComponentized(DotName prefix,
                                          String localName)
Constructs a componentized DotName. Each DotName refers to a parent prefix (or null if there is no further prefix) in addition to a local name that has no dot separator. The fully qualified name this DotName represents is consructed by recursing all parent prefixes and joining all local name values with the '.' character.

Parameters:
prefix - Another DotName that is the portion to the left of localName, this may be null if there is not one
localName - the local non-null portion of this name, which does not contain '.'
Returns:
a componentized DotName.

prefix

public DotName prefix()
Returns the parent prefix for this DotName or null if there is none. Simple DotName variants never have a prefix.

Returns:
the parent prefix for this DotName

local

public String local()
Returns the local portion of this DotName. In simple variants, the entire fully qualified string is returned. In componentized variants, just the right most portion not including a separator is returned.

Returns:
the non-null local portion of this DotName

isComponentized

public boolean isComponentized()
Returns whether this DotName is a componentized variant.

Returns:
true if it is compponentized, false if it is a simple DotName

toString

public String toString()
Returns the regular fully qualifier class name.

Overrides:
toString in class Object
Returns:
The fully qualified class name

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(DotName other)
Specified by:
compareTo in interface Comparable<DotName>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

Java Annotation Indexer 1.0.0.Final-redhat-1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.