treebolic.generator.model
Class ModelUtils

java.lang.Object
  extended by treebolic.generator.model.ModelUtils

public class ModelUtils
extends java.lang.Object

Model utilities

Author:
Bernard Bou

Constructor Summary
ModelUtils()
           
 
Method Summary
private static java.lang.String decode(java.lang.String thisString)
          Decode encoded URL (for display)
private static java.lang.String encode(java.lang.String thisString)
          Encode encoded URL
private static void getIdMap(INode thisNode, java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
          Recursive traversal of nodes for ids
static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getIdMap(Model thisModel)
          Map of ids in this model to their locations
private static void getImageMap(INode thisNode, java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
          Recursive traversal of nodes for images
static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getImageMap(Model thisModel)
          Map of images in this model to their locations
private static void getLinkMap(INode thisNode, java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
          Recursive traversal of nodes for mounts
static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getLinkMap(Model thisModel)
          Map of mounts in this model to their locations
private static void getMountMap(INode thisNode, java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
          Recursive traversal of nodes for mounts
static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getMountMap(Model thisModel)
          Map of mounts in this model to their locations
static java.util.Map<java.lang.String,MutableNode> makeIdToNodeMap(Model thisModel)
          Make id to node map for this model
private static void makeIdToNodeMap(MutableNode thisNode, java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap)
          Make id to node map for this model
private static void normalizeId(TreeMutableNode thisNode, java.lang.String thisPrefix, java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap, java.util.Map<java.lang.String,java.lang.String> thisOldIdToNewIdMap)
          Normalize ids in model
static java.util.Map<java.lang.String,MutableNode> normalizeIds(Model thisModel, java.lang.String thisPrefix)
          Normalize ids in this model
private static void normalizeLinks(TreeMutableNode thisNode, java.util.Map<java.lang.String,java.lang.String> thisOldIdToNewIdMap)
          Normalize node links
private static void putReferenceMapKeyValue(java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap, java.lang.String thisKey, java.lang.String thisValue)
          Put value in multi-valued map
static void saveSettings(Settings theseSettings, java.lang.String thisPropertyFile)
          Save settings to file
static java.util.Properties settingsToProperty(Settings theseSettings)
          Save settings
static TreeMutableNode toMutable(INode thatNode, java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap, java.util.Map<INode,MutableNode> thisOldToNewNodeMap)
          Make of copy of this model with mutable nodes
static Pair<Model,java.util.Map<java.lang.String,MutableNode>> toMutable(Model thisModel)
          Make of copy of this model with mutable nodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelUtils

public ModelUtils()
Method Detail

toMutable

public static Pair<Model,java.util.Map<java.lang.String,MutableNode>> toMutable(Model thisModel)
Make of copy of this model with mutable nodes

Parameters:
thisModel - model
Returns:
equivalent model with mutable nodes

toMutable

public static TreeMutableNode toMutable(INode thatNode,
                                        java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap,
                                        java.util.Map<INode,MutableNode> thisOldToNewNodeMap)
Make of copy of this model with mutable nodes

Parameters:
thatNode - start node
thisIdToNodeMap - id to node map
thisOldToNewNodeMap - old node to new node map
Returns:
equivalent model with mutable nodes

makeIdToNodeMap

public static java.util.Map<java.lang.String,MutableNode> makeIdToNodeMap(Model thisModel)
Make id to node map for this model

Parameters:
thisModel - model
Returns:
id to node map

makeIdToNodeMap

private static void makeIdToNodeMap(MutableNode thisNode,
                                    java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap)
Make id to node map for this model

Parameters:
thisNode - start node
thisIdToNodeMap - id to node result map

normalizeIds

public static java.util.Map<java.lang.String,MutableNode> normalizeIds(Model thisModel,
                                                                       java.lang.String thisPrefix)
Normalize ids in this model

Parameters:
thisModel - model
thisPrefix - id prefix
Returns:
new id to node map

normalizeId

private static void normalizeId(TreeMutableNode thisNode,
                                java.lang.String thisPrefix,
                                java.util.Map<java.lang.String,MutableNode> thisIdToNodeMap,
                                java.util.Map<java.lang.String,java.lang.String> thisOldIdToNewIdMap)
Normalize ids in model

Parameters:
thisNode - node
thisPrefix - id prefix
thisIdToNodeMap - id to node result map
thisOldIdToNewIdMap - old id to new id result map

normalizeLinks

private static void normalizeLinks(TreeMutableNode thisNode,
                                   java.util.Map<java.lang.String,java.lang.String> thisOldIdToNewIdMap)
Normalize node links

Parameters:
thisNode - start node
thisOldIdToNewIdMap - old id to new id map

getImageMap

public static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getImageMap(Model thisModel)
Map of images in this model to their locations

Parameters:
thisModel - model
Returns:
map of images to locations

getImageMap

private static void getImageMap(INode thisNode,
                                java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
Recursive traversal of nodes for images

Parameters:
thisNode - start node
thisMap - map to collect results

getMountMap

public static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getMountMap(Model thisModel)
Map of mounts in this model to their locations

Parameters:
thisModel - model
Returns:
map of mounts to locations

getMountMap

private static void getMountMap(INode thisNode,
                                java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
Recursive traversal of nodes for mounts

Parameters:
thisNode - start node
thisMap - map to collect results

getLinkMap

public static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getLinkMap(Model thisModel)
Map of mounts in this model to their locations

Parameters:
thisModel - model
Returns:
map of mounts to locations

getLinkMap

private static void getLinkMap(INode thisNode,
                               java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
Recursive traversal of nodes for mounts

Parameters:
thisNode - start node
thisMap - map to collect results

getIdMap

public static java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> getIdMap(Model thisModel)
Map of ids in this model to their locations

Parameters:
thisModel - model
Returns:
map of ids to locations

getIdMap

private static void getIdMap(INode thisNode,
                             java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap)
Recursive traversal of nodes for ids

Parameters:
thisNode - start node
thisMap - map to collect results

putReferenceMapKeyValue

private static void putReferenceMapKeyValue(java.util.Map<java.lang.String,java.util.SortedSet<java.lang.String>> thisMap,
                                            java.lang.String thisKey,
                                            java.lang.String thisValue)
Put value in multi-valued map

Parameters:
thisMap - map
thisKey - key
thisValue - value

decode

private static java.lang.String decode(java.lang.String thisString)
Decode encoded URL (for display)

Parameters:
thisString - encode URL string
Returns:
decoded URL string

encode

private static java.lang.String encode(java.lang.String thisString)
Encode encoded URL

Parameters:
thisString - encode URL string
Returns:
decoded URL string

saveSettings

public static void saveSettings(Settings theseSettings,
                                java.lang.String thisPropertyFile)
Save settings to file

Parameters:
thisPropertyFile - property file to save to

settingsToProperty

public static java.util.Properties settingsToProperty(Settings theseSettings)
Save settings

Parameters:
theseSettings - settings to convert to properties