Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/trapezium/chisel/codeveloper/test.java


1   /*
2    * @(#)test.java
3    *
4    * Copyright (c) 1999 by Trapezium Development LLC.  All Rights Reserved.
5    *
6    * The information in this file is the property of Trapezium Development LLC
7    * and may be used only in accordance with the terms of the license granted
8    * by Trapezium.
9    *
10   */
11  package com.trapezium.chisel.codeveloper;
12  
13  import com.trapezium.chisel.Optimizer;
14  import com.trapezium.chisel.TokenPrinter;
15  import com.trapezium.chisel.IntegerConstraints;
16  import com.trapezium.vrml.node.*;
17  import com.trapezium.vrml.fields.*;
18  
19  /**
20   * test is a custom chisel designed by test
21   *
22   * This code was generated by Chisel Developer Kit version 1.0
23   */
24  public class test extends Optimizer {
25    // constants defining options by offset
26    static final int TEST_OPTION = 0;
27  
28    // variables for storing option values
29    int test;
30  
31    public test() {
32      super( "test", "test" );
33      test = 0;
34    }
35  
36    /** reset called just before chisel is run on a new file */
37    public void reset() {
38    }
39  
40    /** Get the number of options available for this chisel */
41    public int getNumberOptions() {
42      return( 1 );
43    }
44  
45    /** Get the data type of an option */
46    public Class getOptionClass( int offset ) {
47      if ( offset == TEST_OPTION ) {
48        return( Integer.TYPE );
49      }
50      return( null );
51    }
52  
53    /** Get the label for an option */
54    public String getOptionLabel( int offset ) {
55      if ( offset == TEST_OPTION ) {
56        return( "test" );
57      }
58      return( null );
59    }
60  
61    /** Get the value of an option */
62    public Object getOptionValue( int offset ) {
63      if ( offset == TEST_OPTION ) {
64        return( intToOptionValue( test ));
65      }
66      return( null );
67    }
68  
69    /** Set the value of an option */
70    public void setOptionValue( int offset, Object value ) {
71      if ( offset == TEST_OPTION ) {
72        test = optionValueToInt( value );
73      }
74    }
75  
76    /** Get the constraints on an option */
77    public Object getOptionConstraints( int offset ) {
78      if ( offset == TEST_OPTION ) {
79        return( new IntegerConstraints( 0, 5, 0 ));
80      }
81      return( null );
82    }
83  
84    /** Check if Node should be modified.
85     * TODO: user defined
86     */
87    boolean optimizationOK( Node n ) {
88      // MUST BE USER DEFINED
89      return( true );
90    }
91  
92    /** Called when node of specified type found in graph traversal */
93    public void attemptOptimization( Node n ) {
94      if ( optimizationOK( n )) {
95        // if you need to access any of the fields, here they are
96        // Field value is null if field not specified in file
97        // 'test' is not a build in node type
98  
99        // register entire node for regeneration
100       // last parameter can be any object, it is passed to "optimize" method
101       // as the "param" parameter
102       replaceRange( n.getFirstTokenOffset(), n.getLastTokenOffset(), n );
103     }
104   }
105 
106   /** Called to regenerate a portion of the text in a file.
107    *
108    *  @param tp object that takes regenerated text, similar to a PrintStream
109    *  @param param Object passed to "replaceRange" in "attemptOptimization" method above
110    *  @param startTokenOffset offset of first token in sequence being regenerated
111    *  @param endTokenOffset offset of last token in sequence being regenerated
112    */
113   public void optimize( TokenPrinter tp, Object param, int startTokenOffset, int endTokenOffset ) {
114     // TODO: user defined
115     // if nothing done here, entire range is removed
116   }
117 
118 }