ptolemy.domains.ptinyos.util.nc2moml
Class MoMLLib

java.lang.Object
  extended by ptolemy.domains.ptinyos.util.nc2moml.MoMLLib

public class MoMLLib
extends java.lang.Object

Traverse a directory tree and generate .moml files. Search the directory tree for files that input suffix (e.g., *.moml) and create files with the name output filename (e.g., index.moml) in each directory that contains an file with the input suffix and in all the parent directories. Existing input suffix files are overwritten.

Usage:

 java -classpath $PTII:$PTII/ptolemy/domains/ptinyos/lib/jdom.jar \
 ptolemy.domains.ptinyos.util.nc2moml.MoMLLib \
 input suffix top-level output filename \
 output filename root dir of input files
 

Example:

 java -classpath $PTII:$PTII/ptolemy/domains/ptinyos/lib/jdom.jar \
 ptolemy.domains.ptinyos.util.nc2moml.MoMLLib \
 .moml _TOSIndex.moml _index.moml $PTII/vendors/ptinyos/moml
 

Since:
Ptolemy II 5.1
Version:
$Id: MoMLLib.java 47513 2007-12-07 06:32:21Z cxh $
Author:
Elaine Cheong, contributor: Christopher Brooks
Accepted Rating:
Red (celaine)
Proposed Rating:
Red (celaine)

Constructor Summary
MoMLLib()
           
 
Method Summary
static void generateIndex(java.lang.String[] components, java.lang.String[] indexFiles, java.lang.String libraryName, java.lang.String outputFile)
          Generate the .moml index file for the given arguments.
static void main(java.lang.String[] args)
          Traverse the directory tree and generate .moml files.
static void proc(java.lang.String inputSuffix, java.lang.String indexFilename, java.lang.String indexFilenameTopLevel, boolean toplevel, java.lang.String root, java.lang.String currentDir)
          Traverse the directory tree recursively and generate .moml index files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoMLLib

public MoMLLib()
Method Detail

generateIndex

public static void generateIndex(java.lang.String[] components,
                                 java.lang.String[] indexFiles,
                                 java.lang.String libraryName,
                                 java.lang.String outputFile)
                          throws java.io.IOException
Generate the .moml index file for the given arguments. Example:
     <?xml version="1.0"?>
     <!DOCTYPE plot PUBLIC "-//UC Berkeley//DTD MoML 1//EN" "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">

     <!--DO NOT EDIT.  This file was generated by ptolemy.domains.ptinyos.util.nc2moml.MoMLLib.  The filename was chosen so that it does not conflict with .nc files of the same name and any other ptII-referenced .moml file in the classpath.-->
     <entity name="Counters" class="ptolemy.moml.EntityLibrary">
     <configure>
     <?moml
     <group>
     <entity name="Counter" class="tos.lib.Counters.Counter" />
     <entity name="IntToLeds" class="tos.lib.Counters.IntToLeds" />
     <entity name="IntToLedsM" class="tos.lib.Counters.IntToLedsM" />
     <entity name="IntToRfm" class="tos.lib.Counters.IntToRfm" />
     <entity name="IntToRfmM" class="tos.lib.Counters.IntToRfmM" />
     <entity name="RfmToInt" class="tos.lib.Counters.RfmToInt" />
     <entity name="RfmToIntM" class="tos.lib.Counters.RfmToIntM" />
     <entity name="SenseToInt" class="tos.lib.Counters.SenseToInt" />
     </group>
     ?>
     </configure>
     </entity>
     

Parameters:
components - Array containing the components in short path format relative to the root. Example: tos/lib/Counters/Counter
libraryName - Name of this directory.
indexFiles - Array containing the sub-index files in short path format relative to the outputFile directory. Example: subdir/_TOSIndex.moml
outputFile - The file to generate in long path format. Example: /home/celaine/ptII/vendors/ptinyos/moml/tos/lib/Counters/Counter/index.moml
Throws:
java.io.IOException - If there is a problem writing files.

main

public static void main(java.lang.String[] args)
Traverse the directory tree and generate .moml files.

Parameters:
args - An array of Strings.
  1. The input suffix.
  2. The top-level output file name.
  3. The output file name
  4. the root directory of the input files.

proc

public static void proc(java.lang.String inputSuffix,
                        java.lang.String indexFilename,
                        java.lang.String indexFilenameTopLevel,
                        boolean toplevel,
                        java.lang.String root,
                        java.lang.String currentDir)
                 throws java.lang.Exception
Traverse the directory tree recursively and generate .moml index files.

Parameters:
inputSuffix - Suffix for the input files to look for.
indexFilename - Name of the index file to look for and generate for non-top level.
indexFilenameTopLevel - Name of the top-level index file to generate.
toplevel - True if this is the top-level call to proc().
root - Root dir of the input files.
currentDir - The current directory in this call to proc().
Throws:
java.lang.Exception - If internal error (duplicate file found or invalid currentDir name.