org.apache.oodt.profile
Class Profile

java.lang.Object
  extended by org.apache.oodt.profile.Profile
All Implemented Interfaces:
Serializable, Cloneable, Comparable, Documentable
Direct Known Subclasses:
SearchableProfile

public class Profile
extends Object
implements Serializable, Cloneable, Comparable, Documentable

A profile. Objects of this class are profiles. Profiles are metadata descriptions of resources.

Author:
Kelly
See Also:
Serialized Form

Field Summary
protected  Map elements
          My elements.
protected  ProfileAttributes profAttr
          My profile attributes.
static String PROFILES_DTD_FPI
          The formal public identifier of the profiles DTD.
static String PROFILES_DTD_URL
          The system identifier of the profiles DTD.
protected  ResourceAttributes resAttr
          My resource attributes.
 
Constructor Summary
Profile()
          Create a blank profile.
Profile(Node root)
          Creates a new Profile instance.
Profile(Node root, ObjectFactory factory)
          Create a profile from an XML document.
Profile(ProfileAttributes profAttr, ResourceAttributes resAttr)
          Create a profile from its attributes.
Profile(String string)
          Create a profile from an XML document.
Profile(String string, ObjectFactory factory)
          Create a profile from an XML document.
 
Method Summary
 void addToModel(com.hp.hpl.jena.rdf.model.Model model)
          Add this profile as an RDF resource description to an RDF model.
 Object clone()
           
 int compareTo(Object rhs)
           
static Document createProfileDocument()
          Create a <profile> document using the profiles DTD.
static List createProfiles(Element root)
          Create a list of profiles by deserializing data from the given XML element.
static List createProfiles(Element root, ObjectFactory factory)
          Create a list of profiles by deserializing data from the given XML element.
static Document createProfilesDocument()
          Create a <profiles> document using the profiles DTD.
 boolean equals(Object rhs)
           
 ProfileAttributes getProfileAttributes()
          Get the profile attributes.
 Map getProfileElements()
          Get the profile elements.
 ResourceAttributes getResourceAttributes()
          Get the resource attributes.
 URI getURI()
           
 int hashCode()
           
static void main(String[] argv)
          Try to parse an XML profile in a file in its XML vocabulary.
 void setProfileAttributes(ProfileAttributes profAttr)
          Set this profile's profile attributes.
 void setResourceAttributes(ResourceAttributes resAttr)
          Set this profile's resource attributes.
 String toString()
           
 Node toXML(Document doc)
          Serialize this profile as an XML node.
 Node toXMLWithoutElements(Document doc)
          Serialize this profile as an XML node but without any elements.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROFILES_DTD_FPI

public static final String PROFILES_DTD_FPI
The formal public identifier of the profiles DTD.

See Also:
Constant Field Values

PROFILES_DTD_URL

public static String PROFILES_DTD_URL
The system identifier of the profiles DTD.


profAttr

protected ProfileAttributes profAttr
My profile attributes.


resAttr

protected ResourceAttributes resAttr
My resource attributes.


elements

protected Map elements
My elements. This mapping is from element name (a String) to ProfileElement.

Constructor Detail

Profile

public Profile()
Create a blank profile.


Profile

public Profile(String string)
        throws SAXException
Create a profile from an XML document.

Parameters:
string - The XML document (as a string).
Throws:
SAXException - If the string can't be parsed.

Profile

public Profile(String string,
               ObjectFactory factory)
        throws SAXException
Create a profile from an XML document.

Parameters:
string - The XML document (as a string).
factory - Object factory to use.
Throws:
SAXException - If the string can't be parsed.

Profile

public Profile(Node root)
Creates a new Profile instance.

Parameters:
root - a Node value.

Profile

public Profile(Node root,
               ObjectFactory factory)
Create a profile from an XML document.

Parameters:
root - The <profile> element.

Profile

public Profile(ProfileAttributes profAttr,
               ResourceAttributes resAttr)
Create a profile from its attributes.

Parameters:
profAttr - Profile attributes.
resAttr - Resource attributes.
Method Detail

createProfiles

public static List createProfiles(Element root,
                                  ObjectFactory factory)
Create a list of profiles by deserializing data from the given XML element.

Parameters:
root - Either a <profiles> or a <profile> element.
factory - Factory for creation of profile-related objects.
Returns:
A list of profiles.

createProfiles

public static List createProfiles(Element root)
Create a list of profiles by deserializing data from the given XML element. This method uses the default factory that yields objects of this package, namely Profile, ProfileAttributes, ResourceAttributes, and ProfileElement and its subclasses.

Parameters:
root - Either a <profiles> or a <profile> element.
Returns:
A list of profiles.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

compareTo

public int compareTo(Object rhs)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
Overrides:
clone in class Object

getProfileAttributes

public ProfileAttributes getProfileAttributes()
Get the profile attributes.

Returns:
The profile attributes.

getResourceAttributes

public ResourceAttributes getResourceAttributes()
Get the resource attributes.

Returns:
The resource attributes.

setProfileAttributes

public void setProfileAttributes(ProfileAttributes profAttr)
Set this profile's profile attributes.

Parameters:
profAttr - a ProfileAttributes value.

setResourceAttributes

public void setResourceAttributes(ResourceAttributes resAttr)
Set this profile's resource attributes.

Parameters:
resAttr - a ResourceAttributes value.

getProfileElements

public Map getProfileElements()
Get the profile elements. The profile elements are a mapping from the element name (String) to ProfileElement.

Returns:
The profile elements.

getURI

public URI getURI()

addToModel

public void addToModel(com.hp.hpl.jena.rdf.model.Model model)
Add this profile as an RDF resource description to an RDF model. This creates a description of the resource that this profile describes, as well as additional resources for the reified statements about the profile itself, and adds them all to the given model.

Parameters:
model - Model to which to add the profile and its related descriptions.

toXML

public Node toXML(Document doc)
           throws DOMException
Serialize this profile as an XML node.

Specified by:
toXML in interface Documentable
Parameters:
doc - The document that will own this node.
Returns:
The XML element <profile> representing these attributes.
Throws:
DOMException - If an error occurs creating the XML nodes.

toXMLWithoutElements

public Node toXMLWithoutElements(Document doc)
                          throws DOMException
Serialize this profile as an XML node but without any elements.

Parameters:
doc - The document that will own this node.
Returns:
The XML element <profile> representing these attributes.
Throws:
DOMException - If an error occurs creating the XML nodes.

createProfilesDocument

public static Document createProfilesDocument()
Create a <profiles> document using the profiles DTD.

Returns:
A <profiles> document with the profiles DTD.

createProfileDocument

public static Document createProfileDocument()
Create a <profile> document using the profiles DTD.

Returns:
A <profile> document with the profiles DTD.

main

public static void main(String[] argv)
                 throws Throwable
Try to parse an XML profile in a file in its XML vocabulary. If successful, you get the profile as RDF document (in XML format) to the standard output after it's been digested by the profile class. If not, then you get an exception.

Parameters:
argv - Command-line arguments, of which there should be one, the name of XML file containing the profile to parse
Throws:
Throwable - if an error occurs.


Copyright © 1999-2011 Apache OODT. All Rights Reserved.