com.sfm.ap210.jsdai.utils
Class SdaiUtils

java.lang.Object
  extended by com.sfm.ap210.jsdai.utils.SdaiUtils

public class SdaiUtils
extends java.lang.Object

This class contains generic utility methods for common SDAI operations and other convenience utilities that may be helpful when dealing with the JSDAI.


Constructor Summary
SdaiUtils()
           
 
Method Summary
static java.util.Set<jsdai.dictionary.EAttribute> allAttributes(jsdai.dictionary.EEntity_definition def)
          Get all attributes defined for the given entity definition
static java.util.Set<jsdai.dictionary.EAttribute> allAttributes(jsdai.lang.EEntity ent)
          Get all attributes defined for the given entity
static java.util.Set<jsdai.dictionary.EEntity_definition> allSupers(jsdai.dictionary.EEntity_definition def)
          Get all super types of the given entity definition
static void close(jsdai.lang.SdaiSession session)
          Close the given SDAI session instance
static
<T> T
create(java.lang.Class<T> type, jsdai.lang.SdaiModel model)
          Create a new instance of the given type in the given model and return the newly create instance
static java.lang.Iterable<jsdai.dictionary.EAttribute> explicitAttributes(jsdai.dictionary.EEntity_definition def)
          Get all explicit attributes defined for the given entity definition
static java.lang.Iterable<jsdai.dictionary.EAttribute> explicitAttributes(jsdai.lang.EEntity ent)
          Get all explicit attributes defined for the given entity
static
<T> T
findFirst(java.lang.Class<T> klass, jsdai.lang.Aggregate agg)
          Find the first entity of the given type in the aggregate instance
static
<T> T
findFirst(java.lang.Class<T> klass, jsdai.lang.SdaiModel model)
          Find the first entity of the given type in the given SDAI model
static
<T> java.util.List<T>
Instances(java.lang.Class<T> klass, jsdai.lang.SdaiModel model)
          Create a list view of all entities in the given model conforming to the given type restriction
static java.lang.Iterable<jsdai.lang.EEntity> Iter(jsdai.lang.Aggregate aggregate)
          Create an iterable view of all entities in the given aggregate
static
<T> java.lang.Iterable<T>
Iter(java.lang.Class<T> klass, jsdai.lang.Aggregate aggregate)
          Create an iterable view of the given aggregate limited to instances that conform to the type given by klass
static jsdai.lang.SdaiModel loadModel(java.io.File file, jsdai.lang.SdaiRepository repo)
          Load the Part21 STEP model contained in the given file into the given repository
static jsdai.lang.SdaiRepository newRepo(jsdai.lang.SdaiSession session, java.lang.String name)
          Create a new repository with the given name in the given SDAI session
static jsdai.lang.SdaiSession newROSession()
          Open a new read-only SDAI session with default configuration
static jsdai.lang.SdaiModel newRWModel(jsdai.lang.SdaiRepository repo, java.lang.String name)
          Create a new read-write enabled AP210 model in the given repository with the given name
static jsdai.lang.SdaiSession newRWSession()
          Open a new read-write SDAI session with default configuration
static java.util.List<jsdai.lang.EEntity> Sequence(jsdai.lang.AEntity aggregate)
          Create a list view of all entities in the given aggregate
static
<T> java.util.List<T>
Sequence(java.lang.Class<T> klass, jsdai.lang.Aggregate aggregate)
          Create a list view of the given aggregate limited to instances that conform to the type given by klass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SdaiUtils

public SdaiUtils()
Method Detail

newRWSession

public static jsdai.lang.SdaiSession newRWSession()
                                           throws jsdai.lang.SdaiException
Open a new read-write SDAI session with default configuration

Returns:
Throws:
jsdai.lang.SdaiException

newROSession

public static jsdai.lang.SdaiSession newROSession()
                                           throws jsdai.lang.SdaiException
Open a new read-only SDAI session with default configuration

Returns:
Throws:
jsdai.lang.SdaiException

newRWModel

public static jsdai.lang.SdaiModel newRWModel(jsdai.lang.SdaiRepository repo,
                                              java.lang.String name)
                                       throws jsdai.lang.SdaiException
Create a new read-write enabled AP210 model in the given repository with the given name

Parameters:
repo -
name -
Returns:
Throws:
jsdai.lang.SdaiException

newRepo

public static jsdai.lang.SdaiRepository newRepo(jsdai.lang.SdaiSession session,
                                                java.lang.String name)
                                         throws jsdai.lang.SdaiException
Create a new repository with the given name in the given SDAI session

Parameters:
session -
name -
Returns:
Throws:
jsdai.lang.SdaiException

loadModel

public static jsdai.lang.SdaiModel loadModel(java.io.File file,
                                             jsdai.lang.SdaiRepository repo)
                                      throws jsdai.lang.SdaiException
Load the Part21 STEP model contained in the given file into the given repository

Parameters:
file -
repo -
Returns:
Throws:
jsdai.lang.SdaiException

Iter

public static <T> java.lang.Iterable<T> Iter(java.lang.Class<T> klass,
                                             jsdai.lang.Aggregate aggregate)
                                  throws jsdai.lang.SdaiException
Create an iterable view of the given aggregate limited to instances that conform to the type given by klass

Type Parameters:
T -
Parameters:
klass - the type restriction of returned aggregate items
aggregate - the aggregate instance
Returns:
an iterable view of the items of the aggregate conforming to the given type restriction
Throws:
jsdai.lang.SdaiException

Sequence

public static <T> java.util.List<T> Sequence(java.lang.Class<T> klass,
                                             jsdai.lang.Aggregate aggregate)
                                  throws jsdai.lang.SdaiException
Create a list view of the given aggregate limited to instances that conform to the type given by klass

Type Parameters:
T -
Parameters:
klass - the type restriction of returned aggregate items
aggregate - the aggregate instance
Returns:
a list view of the items of the aggregate conforming to the given type restriction
Throws:
jsdai.lang.SdaiException

Iter

public static java.lang.Iterable<jsdai.lang.EEntity> Iter(jsdai.lang.Aggregate aggregate)
                                                   throws jsdai.lang.SdaiException
Create an iterable view of all entities in the given aggregate

Parameters:
aggregate -
Returns:
Throws:
jsdai.lang.SdaiException

Sequence

public static java.util.List<jsdai.lang.EEntity> Sequence(jsdai.lang.AEntity aggregate)
                                                   throws jsdai.lang.SdaiException
Create a list view of all entities in the given aggregate

Parameters:
aggregate -
Returns:
Throws:
jsdai.lang.SdaiException

Instances

public static <T> java.util.List<T> Instances(java.lang.Class<T> klass,
                                              jsdai.lang.SdaiModel model)
                                   throws jsdai.lang.SdaiException
Create a list view of all entities in the given model conforming to the given type restriction

Type Parameters:
T - the EEntity type restriction
Parameters:
klass - the type to filter for
model - the SDAI model instance to search
Returns:
all instances from the given model conforming to the given type restriction
Throws:
jsdai.lang.SdaiException

close

public static void close(jsdai.lang.SdaiSession session)
                  throws jsdai.lang.SdaiException
Close the given SDAI session instance

Parameters:
session -
Throws:
jsdai.lang.SdaiException

create

public static <T> T create(java.lang.Class<T> type,
                           jsdai.lang.SdaiModel model)
                throws jsdai.lang.SdaiException
Create a new instance of the given type in the given model and return the newly create instance

Type Parameters:
T - the entity type to create in the model
Parameters:
type - the class object of the entity type to create
model - the model instance
Returns:
the newly created entity instance
Throws:
jsdai.lang.SdaiException

allSupers

public static java.util.Set<jsdai.dictionary.EEntity_definition> allSupers(jsdai.dictionary.EEntity_definition def)
                                                                    throws jsdai.lang.SdaiException
Get all super types of the given entity definition

Parameters:
def -
Returns:
Throws:
jsdai.lang.SdaiException

explicitAttributes

public static java.lang.Iterable<jsdai.dictionary.EAttribute> explicitAttributes(jsdai.dictionary.EEntity_definition def)
                                                                          throws jsdai.lang.SdaiException
Get all explicit attributes defined for the given entity definition

Parameters:
def -
Returns:
Throws:
jsdai.lang.SdaiException

explicitAttributes

public static java.lang.Iterable<jsdai.dictionary.EAttribute> explicitAttributes(jsdai.lang.EEntity ent)
                                                                          throws jsdai.lang.SdaiException
Get all explicit attributes defined for the given entity

Parameters:
ent -
Returns:
Throws:
jsdai.lang.SdaiException

allAttributes

public static java.util.Set<jsdai.dictionary.EAttribute> allAttributes(jsdai.dictionary.EEntity_definition def)
                                                                throws jsdai.lang.SdaiException
Get all attributes defined for the given entity definition

Parameters:
def -
Returns:
Throws:
jsdai.lang.SdaiException

allAttributes

public static java.util.Set<jsdai.dictionary.EAttribute> allAttributes(jsdai.lang.EEntity ent)
                                                                throws jsdai.lang.SdaiException
Get all attributes defined for the given entity

Parameters:
ent -
Returns:
Throws:
jsdai.lang.SdaiException

findFirst

public static <T> T findFirst(java.lang.Class<T> klass,
                              jsdai.lang.Aggregate agg)
                   throws jsdai.lang.SdaiException
Find the first entity of the given type in the aggregate instance

Type Parameters:
T - the type of entity to find
Parameters:
klass - the class object of the entity's type
agg - the aggregate to search
Returns:
the first instance found or null if no instance is found
Throws:
jsdai.lang.SdaiException

findFirst

public static <T> T findFirst(java.lang.Class<T> klass,
                              jsdai.lang.SdaiModel model)
                   throws jsdai.lang.SdaiException
Find the first entity of the given type in the given SDAI model

Type Parameters:
T - the type of entity to find
Parameters:
klass - the class object of the entity's type
model - the model to search
Returns:
the first instance found or null if no instance is found
Throws:
jsdai.lang.SdaiException