Sun SPOT API
Green Release  


com.sun.squawk
Class Suite

java.lang.Object
  extended by com.sun.squawk.Suite

public final class Suite
extends Object

A suite is the unit of deployment/compilation in the Squawk system.


Field Summary
static int APPLICATION
          Denotes a suite that encapsulates an application.
static int DEBUG
          Denotes a suite that is being debugged.
static int EXTENDABLE_LIBRARY
          Denotes a suite that encapsulates an open library.
static int LIBRARY
          Denotes a suite that encapsulates a library.
static String PROPERTIES_MANIFEST_RESOURCE_NAME
          Denotes the name of the resource that represents the resource name from which I extract properties from when an installResource(ResourceFile) is done.
 
Method Summary
 void close()
          Closes this suite.
 boolean equals(Object other)
          Compares this suite with another object for equality.
 int getClassCount()
          Gets the number of classes in this suite.
 String getConfiguration()
          Gets the configuration of the suite.
 Klass getKlass(int suiteID)
          Gets the class in this suite corresponding to a given class number.
 String getManifestProperty(String name)
          Gets the value of an PROPERTIES_MANIFEST_RESOURCE_NAME property embedded in the suite.
 String getName()
          Gets this suite's name.
 int getNextAvailableClassNumber()
          Gets the next available number for a class that will be installed in this suite.
 Suite getParent()
          Gets the parent suite of this suite.
 InputStream getResourceAsStream(String name, Klass klass)
          Finds a resource with a given name.
 byte[] getResourceData(String name)
          Gets the contents of a resource file embedded in the suite.
static Suite getSuite(String uri)
          Gets the Suite corresponding to a given URI, loading it if necessary.
 String getURI()
          Gets the URI identifier of the serialized form of this suite.
 int hashCode()
          Returns a hashcode for this suite which is derived solely from the suite's name.
 void installClass(Klass klass)
          Installs a given class into this suite.
 void installProperty(ManifestProperty property)
          Installs a collection of IMlet property values into this suite.
 void installResource(ResourceFile resourceFile)
          Installs a collection of resource files into this suite.
 boolean isBootstrap()
          Determines if this is the bootstrap suite containing the system classes.
 boolean isClosed()
          Determines if this suite is closed.
protected  void loadProperties(byte[] bytes)
          Parse properties from jar manifest file.
 Klass lookup(String name)
          Gets the Klass instance from this suite corresponding to a specified class name in internal form.
 void printAPI(PrintStream out)
          Prints a textual description of the components in this suite that can be linked against.
 void save(DataOutputStream dos, String uri)
          Serializes the object graph rooted by this suite and writes it to a given stream.
 void save(DataOutputStream dos, String uri, boolean bigEndian)
          Serializes the object graph rooted by this suite and writes it to a given stream.
 Suite strip(int type)
          Creates a copy of this suite with its symbolic information stripped according to the given parameters.
 String toString()
          Gets a string representation of this suite.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLICATION

public static final int APPLICATION
Denotes a suite that encapsulates an application. The classes of an application can not be linked against.

See Also:
Constant Field Values

LIBRARY

public static final int LIBRARY
Denotes a suite that encapsulates a library. The classes of a library can be linked against but the library itself cannot be extended by virtue of other classes linking against it's package private components.

See Also:
Constant Field Values

EXTENDABLE_LIBRARY

public static final int EXTENDABLE_LIBRARY
Denotes a suite that encapsulates an open library. The classes of an open library can be linked against and the library itself can be extended by virtue of other classes linking against it's package private components.

See Also:
Constant Field Values

DEBUG

public static final int DEBUG
Denotes a suite that is being debugged. This suite retains all its symbolic information when closed.

See Also:
Constant Field Values

PROPERTIES_MANIFEST_RESOURCE_NAME

public static final String PROPERTIES_MANIFEST_RESOURCE_NAME
Denotes the name of the resource that represents the resource name from which I extract properties from when an installResource(ResourceFile) is done.

See Also:
Constant Field Values
Method Detail

getName

public String getName()
Gets this suite's name.

Returns:
this suite's name

getParent

public Suite getParent()
Gets the parent suite of this suite.

Returns:
the parent suite of this suite

getURI

public String getURI()
Gets the URI identifier of the serialized form of this suite.

Returns:
the URI from which this suite was loaded or null if the suite was dynamically created

getClassCount

public int getClassCount()
Gets the number of classes in this suite.

Returns:
the number of classes in this suite

isClosed

public boolean isClosed()
Determines if this suite is closed. Open an open suite can have classes installed in it.

Returns:
boolean

isBootstrap

public boolean isBootstrap()
Determines if this is the bootstrap suite containing the system classes.

Returns:
true if this suite has no parent

getNextAvailableClassNumber

public int getNextAvailableClassNumber()
Gets the next available number for a class that will be installed in this suite. The value returned by this method will never be the same for this suite.

Returns:
the next available number for a class that will be installed in this suite

getKlass

public Klass getKlass(int suiteID)
Gets the class in this suite corresponding to a given class number.

Parameters:
suiteID - the class number of the class to retrieve
Returns:
the class corresponding to suiteID

getResourceData

public byte[] getResourceData(String name)
Gets the contents of a resource file embedded in the suite.

Parameters:
name - the name of the resource file whose contents is to be retrieved
Returns:
the resource data, or null if the resource file doesn't exist

getManifestProperty

public String getManifestProperty(String name)
Gets the value of an PROPERTIES_MANIFEST_RESOURCE_NAME property embedded in the suite.

Parameters:
name - the name of the property whose value is to be retrieved
Returns:
the property value

getResourceAsStream

public final InputStream getResourceAsStream(String name,
                                             Klass klass)
Finds a resource with a given name. This method returns null if no resource with this name is found. The rules for searching resources associated with a given class are profile specific.

Parameters:
name - name of the desired resource
klass - Used to get the absolute path to resource if name is not absolute, if null, then assume resource name is absolute
Returns:
a java.io.InputStream object.
Since:
JDK1.1

toString

public String toString()
Gets a string representation of this suite. The string returned is name of this suite with "suite " prepended.

Overrides:
toString in class Object
Returns:
the name of this suite with "suite " prepended

installClass

public void installClass(Klass klass)
Installs a given class into this suite.

Parameters:
klass - the class to install

installResource

public void installResource(ResourceFile resourceFile)
Installs a collection of resource files into this suite.

Parameters:
resources - array of resource files to install

loadProperties

protected void loadProperties(byte[] bytes)
Parse properties from jar manifest file. Based on manifest spec: http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html ABOUT "application descriptors", WHICH ARE NOT SUPPORTED BY THIS METHOD: Note that this syntax is slightly different than the "application descriptor" syntax in the IMP and MIDP specs. An "application descriptor" does not support "continuation lines", or trailing spaces in a value. This is an known annoyance of the MIDP spec. In addition, the MIDP 1.0 and IMP 1.0 specs have in a bug in the BNF, such that white space is REQUIRED before and after the value. The MIDP 2.0 specs correctly show that such white space is optional.


installProperty

public void installProperty(ManifestProperty property)
Installs a collection of IMlet property values into this suite.

Parameters:
properties - IMlet properties array to install

lookup

public Klass lookup(String name)
Gets the Klass instance from this suite corresponding to a specified class name in internal form.

Parameters:
name - the name (in internal form) of the class to lookup
Returns:
the Klass instance corresponding to internalName or null if there isn't one.

equals

public final boolean equals(Object other)
Compares this suite with another object for equality. The result is true if and only if other is a Suite instance and its name is equal to this suite's name.

Overrides:
equals in class Object
Parameters:
other - the object to compare this suite against
Returns:
true if other is a Suite instance and its name is equal to this suite's name
See Also:
Boolean.hashCode(), Hashtable

hashCode

public final int hashCode()
Returns a hashcode for this suite which is derived solely from the suite's name.

Overrides:
hashCode in class Object
Returns:
the hashcode of this suite's name
See Also:
Object.equals(java.lang.Object), Hashtable

getSuite

public static Suite getSuite(String uri)
Gets the Suite corresponding to a given URI, loading it if necessary.

Parameters:
uri - the URI identifying the object memory
Returns:
the Suite inside the object memory identified by uri
Throws:
java.lang.LinkageError - if the suite denoted by URI is not available or there was a problem while loading it

getConfiguration

public String getConfiguration()
Gets the configuration of the suite.

Returns:
the configuration of the suite

save

public void save(DataOutputStream dos,
                 String uri)
          throws IOException
Serializes the object graph rooted by this suite and writes it to a given stream. The endianess of the serialized object graph is the endianess of the unerdlying platform.

Parameters:
dos - the DataOutputStream to which the serialized suite should be written
uri - the URI identifier of the serialized suite
Throws:
OutOfMemoryError - if there was insufficient memory to do the save
IOException - if there was some IO problem while writing the output

save

public void save(DataOutputStream dos,
                 String uri,
                 boolean bigEndian)
          throws IOException
Serializes the object graph rooted by this suite and writes it to a given stream.

Parameters:
dos - the DataOutputStream to which the serialized suite should be written
uri - the URI identifier of the serialized suite
bigEndian - the endianess to be used when serializing this suite
Throws:
OutOfMemoryError - if there was insufficient memory to do the save
IOException - if there was some IO problem while writing the output

close

public void close()
Closes this suite. Once closed, a suite is immutable (and may well reside in read-only memory) and cannot have any more classes installed in it


strip

public Suite strip(int type)
Creates a copy of this suite with its symbolic information stripped according to the given parameters.

Parameters:
type - specifies the type of the suite after closing. Must be APPLICATION, LIBRARY, EXTENDABLE_LIBRARY or DEBUG.

printAPI

public void printAPI(PrintStream out)
Prints a textual description of the components in this suite that can be linked against. That is, the components whose symbolic information has not been stripped.

Parameters:
out - where to print the description

Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.