org.jboss.dna.connector.federation.contribution
Class Contribution

java.lang.Object
  extended by org.jboss.dna.connector.federation.contribution.Contribution
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EmptyContribution, NonEmptyContribution

@Immutable
public abstract class Contribution
extends Object
implements Serializable

The contribution of a source to the information for a single federated node. Users of this interface should treat contributions as generally being immutable, since some implementation will be immutable and will return immutable properties and children containers. Thus, rather than make changes to an existing contribution, a new contribution is created to replace the previous contribution.

Author:
Randall Hauch
See Also:
Serialized Form

Method Summary
static Contribution create(String sourceName, String workspaceName, DateTime expirationTime)
          Create an empty contribution from the named source.
static Contribution create(String sourceName, String workspaceName, Location locationInSource, DateTime expirationTime, Collection<Property> properties, List<Location> children)
          Create a contribution of the supplied properties and children from the named source.
static Contribution create(String sourceName, String workspaceName, Location locationInSource, DateTime expirationTime, Location child)
          Create a contribution of a single child from the named source.
static Contribution create(String sourceName, String workspaceName, Location locationInSource, DateTime expirationTime, Location child1, Location child2)
          Create a contribution of a single child from the named source.
static Contribution create(String sourceName, String workspaceName, Location locationInSource, DateTime expirationTime, Property property)
          Create a contribution of a single property from the named source.
static Contribution createPlaceholder(String sourceName, String workspaceName, Location locationInSource, DateTime expirationTime, List<Location> children)
          Create a placeholder contribution of the supplied properties and children from the named source.
static Contribution createPlaceholder(String sourceName, String workspaceName, Location locationInSource, DateTime expirationTime, Location child)
          Create a placeholder contribution of a single child from the named source.
 boolean equals(Object obj)
           This implementation only compares the source name.
 Iterator<Location> getChildren()
          Get the children that make up this contribution.
 int getChildrenCount()
          Get the number of children that make up this contribution.
 DateTime getExpirationTimeInUtc()
          Get the expiration time, already in UTC.
abstract  Location getLocationInSource()
          Get the source-specific location of this information.
 Iterator<Property> getProperties()
          Get the properties that are in this contribution.
 Property getProperty(Name name)
          Get the contributed property with the supplied name.
 int getPropertyCount()
          Get the number of properties that are in this contribution.
 String getSourceName()
          Get the name of the source that made this contribution.
 String getString(NamespaceRegistry registry)
           
 String getWorkspaceName()
          Get the name of the workspace in the source from which this contribution came.
 int hashCode()
           This implementation returns the hash code of the source name, and is compatible with the implementation of equals(Object).
 boolean isEmpty()
          Return whether this contribution is an empty contribution.
 boolean isExpired(DateTime utcTime)
          Determine whether this contribution has expired given the supplied current time.
 boolean isPlaceholder()
          Determine whether this contribution is considered a placeholder necessary solely because the same source has contributions at or below the children.
 String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static Contribution create(String sourceName,
                                  String workspaceName,
                                  DateTime expirationTime)
Create an empty contribution from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
Returns:
the contribution

create

public static Contribution create(String sourceName,
                                  String workspaceName,
                                  Location locationInSource,
                                  DateTime expirationTime,
                                  Property property)
Create a contribution of a single property from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
locationInSource - the location in the source for this contributed information; may not be null
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
property - the property from the source; may not be null
Returns:
the contribution

create

public static Contribution create(String sourceName,
                                  String workspaceName,
                                  Location locationInSource,
                                  DateTime expirationTime,
                                  Location child)
Create a contribution of a single child from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
locationInSource - the path in the source for this contributed information; may not be null
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
child - the child from the source; may not be null or empty
Returns:
the contribution

create

public static Contribution create(String sourceName,
                                  String workspaceName,
                                  Location locationInSource,
                                  DateTime expirationTime,
                                  Location child1,
                                  Location child2)
Create a contribution of a single child from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
locationInSource - the path in the source for this contributed information; may not be null
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
child1 - the first child from the source; may not be null or empty
child2 - the second child from the source; may not be null or empty
Returns:
the contribution

create

public static Contribution create(String sourceName,
                                  String workspaceName,
                                  Location locationInSource,
                                  DateTime expirationTime,
                                  Collection<Property> properties,
                                  List<Location> children)
Create a contribution of the supplied properties and children from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
locationInSource - the path in the source for this contributed information; may not be null
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
properties - the properties from the source; may not be null
children - the children from the source; may not be null or empty
Returns:
the contribution

createPlaceholder

public static Contribution createPlaceholder(String sourceName,
                                             String workspaceName,
                                             Location locationInSource,
                                             DateTime expirationTime,
                                             Location child)
Create a placeholder contribution of a single child from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
locationInSource - the path in the source for this contributed information; may not be null
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
child - the child from the source; may not be null or empty
Returns:
the contribution

createPlaceholder

public static Contribution createPlaceholder(String sourceName,
                                             String workspaceName,
                                             Location locationInSource,
                                             DateTime expirationTime,
                                             List<Location> children)
Create a placeholder contribution of the supplied properties and children from the named source.

Parameters:
sourceName - the name of the source, which may not be null or blank
workspaceName - the name of the workspace, which may not be null or blank
locationInSource - the path in the source for this contributed information; may not be null
expirationTime - the time (in UTC) after which this contribution should be considered expired, or null if there is no expiration time
children - the children from the source; may not be null or empty
Returns:
the contribution

getSourceName

public String getSourceName()
Get the name of the source that made this contribution.

Returns:
the name of the contributing source

getWorkspaceName

public String getWorkspaceName()
Get the name of the workspace in the source from which this contribution came.

Returns:
the name of the workspace

getLocationInSource

public abstract Location getLocationInSource()
Get the source-specific location of this information.

Returns:
the location as known to the source, or null for EmptyContribution

isExpired

public boolean isExpired(DateTime utcTime)
Determine whether this contribution has expired given the supplied current time.

Parameters:
utcTime - the current time expressed in UTC; may not be null
Returns:
true if at least one contribution has expired, or false otherwise

getExpirationTimeInUtc

public DateTime getExpirationTimeInUtc()
Get the expiration time, already in UTC.

Returns:
the expiration time in UTC

getProperties

public Iterator<Property> getProperties()
Get the properties that are in this contribution. This resulting iterator does not support removal.

Returns:
the properties; never null

getPropertyCount

public int getPropertyCount()
Get the number of properties that are in this contribution.

Returns:
the number of properties

getProperty

public Property getProperty(Name name)
Get the contributed property with the supplied name.

Parameters:
name - the name of the property
Returns:
the contributed property that matches the name, or null if no such property is in the contribution

getChildren

public Iterator<Location> getChildren()
Get the children that make up this contribution. This resulting iterator does not support removal .

Returns:
the children; never null

getChildrenCount

public int getChildrenCount()
Get the number of children that make up this contribution.

Returns:
the number of children

isEmpty

public boolean isEmpty()
Return whether this contribution is an empty contribution.

Returns:
true if this contribution is empty, or false otherwise

isPlaceholder

public boolean isPlaceholder()
Determine whether this contribution is considered a placeholder necessary solely because the same source has contributions at or below the children.

Returns:
true if a placeholder contribution, or false otherwise

hashCode

public int hashCode()

This implementation returns the hash code of the source name, and is compatible with the implementation of equals(Object).

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

getString

public String getString(NamespaceRegistry registry)

equals

public boolean equals(Object obj)

This implementation only compares the source name.

Overrides:
equals in class Object


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.