com.sourceforge.jpatterns.utils
Class CastorUtils

java.lang.Object
  extended by com.sourceforge.jpatterns.utils.CastorUtils

public class CastorUtils
extends Object

This class contains the castor utils related to the JPatterns project (appropriate project specific model is used here).

$Author:: zmicer $
$Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$


Field Summary
protected static String GROUP_ITEM_CLASS_NAME
          Base name of the class to be used.
static org.apache.log4j.Logger LOG
          Logger instance.
 
Constructor Summary
CastorUtils()
           
 
Method Summary
static void addConfig(com.sourceforge.jpatterns.schema.JPatternsConfig config, com.sourceforge.jpatterns.schema.Config configItem)
          Add the instance of Config type to the provided JPatternsConfig root config object
static void addFactory(com.sourceforge.jpatterns.schema.JPatternsConfig config, com.sourceforge.jpatterns.schema.Factory factoryItem)
          Add the instance of Config type to the provided JPatternsConfig root config object
static com.sourceforge.jpatterns.schema.CastorGroupTypeItem constructGroupItem(com.sourceforge.jpatterns.schema.CastorNameScopePriorityType object)
          Construct the CastorGroupTypeItem (choice object) using the provided Object.
static List<com.sourceforge.jpatterns.schema.CastorNameScopePriorityType> extractCastorNameScopePriorityTypeObjects(com.sourceforge.jpatterns.schema.CastorSectionType sectionType)
          Extract all the possible CastorNameScopePriorityType castor objects from the provided CastorSectionType.
static List<com.sourceforge.jpatterns.schema.CastorSectionType> extractCastorSectionTypeObjects(com.sourceforge.jpatterns.schema.JPatternsConfig config)
          Stores and retrive all the objects of CastorSectionType (it means all the objects of this type and also child of this type).
static List<com.sourceforge.jpatterns.schema.Config> getConfig(com.sourceforge.jpatterns.schema.JPatternsConfig config)
          Get the List of Config castor objects by the root JPatterns configuration object.
static List<com.sourceforge.jpatterns.schema.Factory> getFactory(com.sourceforge.jpatterns.schema.JPatternsConfig config)
          Get the List of Factory castor objects by the root JPatterns configuration object.
static com.sourceforge.jpatterns.schema.JPatternsConfig getJPatternsConfig(File file)
          Get JPatternsConfig using the provided file.
static int getPriority(com.sourceforge.jpatterns.schema.CastorNameScopePriorityType castor)
          Get the int representation of the priority.
static void makePrioritized(com.sourceforge.jpatterns.schema.JPatternsConfig castorConfig)
          All the items of the provided JPatternsConfig - sections, business items - are made prioritized.
static void makePrioritized(JPatternsConfigBaseBean bean)
          Make prioritized the provided bean.
protected static void setValidatePriority(com.sourceforge.jpatterns.schema.CastorNameScopePriorityType castor, boolean makePrioritized)
          Set new / validate (is any) the priority field of the given castor object.
static String toString(com.sourceforge.jpatterns.schema.CastorSectionType section, com.sourceforge.jpatterns.schema.CastorNameScopePriorityType item)
          Get the String representation of the Item in the format we need (the full path would be provided).
static void validateAndNormalizeScopesPriorities(com.sourceforge.jpatterns.schema.JPatternsConfig config)
          Make the scopes of all the elements here normalized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Logger instance.


GROUP_ITEM_CLASS_NAME

protected static final String GROUP_ITEM_CLASS_NAME
Base name of the class to be used.

Constructor Detail

CastorUtils

public CastorUtils()
Method Detail

getJPatternsConfig

public static com.sourceforge.jpatterns.schema.JPatternsConfig getJPatternsConfig(File file)
Get JPatternsConfig using the provided file.

Parameters:
file - File using which we need to obtain JPatternsConfig Can not be null (otherwise IllegalArgumentException would appear), also should point to the existed file (otherwise IllegalArgumentException would appear).
Returns:
the castor object, JPatternsConfig. In the case of the failure it returns null $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

extractCastorSectionTypeObjects

public static List<com.sourceforge.jpatterns.schema.CastorSectionType> extractCastorSectionTypeObjects(com.sourceforge.jpatterns.schema.JPatternsConfig config)
Stores and retrive all the objects of CastorSectionType (it means all the objects of this type and also child of this type). This would be performed trough the reflexion. This method is necessary because it doesn could be used without any changes in the case some new types - childs of CastorSectionType would be added - so we won't need to change the sources.

Parameters:
config - JPatternsConfig object to be parsed. Can not be null (otherwise IllegalArgumentException would appear).
Returns:
List of CastorSectionType objects, could be empty List returned in the case the provided config doesn't store the necessary objects $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

extractCastorNameScopePriorityTypeObjects

public static List<com.sourceforge.jpatterns.schema.CastorNameScopePriorityType> extractCastorNameScopePriorityTypeObjects(com.sourceforge.jpatterns.schema.CastorSectionType sectionType)
Extract all the possible CastorNameScopePriorityType castor objects from the provided CastorSectionType. The sense of this method is as follows: CastorSectionType is a base "sections" object and has lots of child with the business items which are the instances of the class CastorNameScopePriorityType. In the case of CastorFactoryType, CastorConfigType it would be just method getItem returning Item[] which are instances of CastorNameScopePriorityType too. But for the castorGroupType it is the method getCastorGroupTypeItem returning CastorGroupTypeItem[] each of them is a choice - in this case we would call "getChoiceValue" method.

Parameters:
sectionType - the section type to be analyzed. Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of the CastorNameScopePriorityType objects. $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

validateAndNormalizeScopesPriorities

public static void validateAndNormalizeScopesPriorities(com.sourceforge.jpatterns.schema.JPatternsConfig config)
Make the scopes of all the elements here normalized. Currently (possibly smth. could be changed) it means:
1. the scopes of the root/child elements can be different 2. in the case "business" item is defined with scope and parent without - the defined scope would have power on the business item 3. in the case the parent elements is defined with a scope, then all the childs of it would be of the appropriate scope
The default scope is mentioned is either the default scope of the castor root config or com.sourceforge.jpatterns.core.JPConstants.DEFAULT_SCOPE_NAME
note1 [zmicer]: think over the adjustment of principles of normalization, as some new types could appear here, and this method would be extended (new scope supported types different from the base type CastorSectionType would appear). note2 [zmicer]: earlier at this method we retrict the case when parent and child have different scopes - for now it is allowed (it was decided to allow the support of scopes of the business item elements inside the section - it is one more scope visibility area).

Parameters:
config - castor root config objects to be processed. Can not be null (otherwise IllegalArgumentException would appear).

makePrioritized

public static void makePrioritized(com.sourceforge.jpatterns.schema.JPatternsConfig castorConfig)
All the items of the provided JPatternsConfig - sections, business items - are made prioritized. For this com.sourceforge.jpatterns.core.JPConstants.PRIORITIZED_PRIOTITY_PREFIX would be added as the prefix to all the priorities. Then later, during the prioritized merging this items would have priority over the identical, but without this prefix.
This functionality is introduced to make the algorithm of simlple merging of JPatterns configuration files identical with the merging with priority (when some configuration takes the priority).

Parameters:
castorConfig - the target JPatternsConfig root castor object objects of which should be modified (their priorities) Can not be null (otherwise IllegalArgumentException would appear). $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

makePrioritized

public static void makePrioritized(JPatternsConfigBaseBean bean)
Make prioritized the provided bean.

Parameters:
bean - the instance to be prioritized. $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

setValidatePriority

protected static void setValidatePriority(com.sourceforge.jpatterns.schema.CastorNameScopePriorityType castor,
                                          boolean makePrioritized)
Set new / validate (is any) the priority field of the given castor object.

Parameters:
castor - CastorNameScopePriorityType instance. Can not be null (otherwise IllegalArgumentException would appear).
makePrioritized - signs if we need to make the priority prioritized (using JPConstants.PRIORITIZED_PRIOTITY_PREFIX) $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

getPriority

public static int getPriority(com.sourceforge.jpatterns.schema.CastorNameScopePriorityType castor)
Get the int representation of the priority.

Parameters:
castor - castor object storing the priority to be used. Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the int representaotion $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

getConfig

public static List<com.sourceforge.jpatterns.schema.Config> getConfig(com.sourceforge.jpatterns.schema.JPatternsConfig config)
Get the List of Config castor objects by the root JPatterns configuration object. It is necessary for the convinient opering with the Config object.

Parameters:
config - the JPatternsConfig root castor config objects, Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of the Config castor object we need, the empty List is returned in the case there are not Config objects. $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

getFactory

public static List<com.sourceforge.jpatterns.schema.Factory> getFactory(com.sourceforge.jpatterns.schema.JPatternsConfig config)
Get the List of Factory castor objects by the root JPatterns configuration object. It is necessary for the convinient opering with the Factory object.

Parameters:
config - the JPatternsConfig root castor config objects, Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of the Factory castor object we need, the empty List is returned in the case there are not Config objects. $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

addConfig

public static void addConfig(com.sourceforge.jpatterns.schema.JPatternsConfig config,
                             com.sourceforge.jpatterns.schema.Config configItem)
Add the instance of Config type to the provided JPatternsConfig root config object

Parameters:
config - JPatternsConfig, Can not be null (otherwise IllegalArgumentException would appear).
configItem - Config castor object. Can not be null (otherwise IllegalArgumentException would appear). $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

addFactory

public static void addFactory(com.sourceforge.jpatterns.schema.JPatternsConfig config,
                              com.sourceforge.jpatterns.schema.Factory factoryItem)
Add the instance of Config type to the provided JPatternsConfig root config object

Parameters:
config - JPatternsConfig, Can not be null (otherwise IllegalArgumentException would appear).
factoryItem - Factory castor object. Can not be null (otherwise IllegalArgumentException would appear). $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

constructGroupItem

public static com.sourceforge.jpatterns.schema.CastorGroupTypeItem constructGroupItem(com.sourceforge.jpatterns.schema.CastorNameScopePriorityType object)
Construct the CastorGroupTypeItem (choice object) using the provided Object.

Parameters:
object - CastorNameScopePriorityType instance, can not be null, CastorGroupTypeItem should have appropriate method set***, where *** - the base name of the provided object. Otherwise IllegalArgumentException would appeared
Returns:
the constructed CastorGroupTypeItem $Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$

toString

public static String toString(com.sourceforge.jpatterns.schema.CastorSectionType section,
                              com.sourceforge.jpatterns.schema.CastorNameScopePriorityType item)
Get the String representation of the Item in the format we need (the full path would be provided). note [zmicer]: be noticed the both name and scope values should be filled for these object passed here

Parameters:
section - the Section object for which we need to get the full representation in the format we need Could be null, in this case information about the section is displayed
item - Item castor object. Can not be null (otherwise IllegalArgumentException would appear). Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the String representation we could use later.


Copyright © 2007 jzmicer.team. All Rights Reserved.