Clover coverage report - Code Coverage for hivemind release 1.1-alpha-1
Coverage timestamp: Tue Jan 18 2005 07:55:08 EST
file stats: LOC: 65   Methods: 0
NCLOC: 11   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Translator.java - - - -
coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.schema;
 16   
 
 17   
 import org.apache.hivemind.Location;
 18   
 import org.apache.hivemind.internal.Module;
 19   
 
 20   
 /**
 21   
  * Object which can translate a string into an object value.  This is used to
 22   
  * translate attribute values (or element content) from strings into
 23   
  * numbers, booleans or other constructs before assigning the final value
 24   
  * to a propery.  Translation occurs after symbol substitution.
 25   
  * 
 26   
  * <p>
 27   
  * Translator classes should have a public constructor that takes no
 28   
  * arguments.  They may optionally have a second constructor
 29   
  * that takes a single string as a parameter.  When the
 30   
  * {@link org.apache.hivemind.parse.DescriptorParser} encounters
 31   
  * a <code>translator</code> of the form 
 32   
  * "<code><i>translator-id</i>,<i>initialization-string</i></code>"
 33   
  * (example: "int,min=0") it will use the second constructor, passing
 34   
  * the initialization string.
 35   
  * 
 36   
  * <p>
 37   
  * Generally, initializion strings are of the form
 38   
  * <code><i>key</i>=<i>value</i>[,<i>key</i>=<i>value</i>]*</code>.
 39   
  * Each initializer has a set of keys it recognizes, other keys are simply
 40   
  * ignored.
 41   
  *
 42   
  * @author Howard Lewis Ship
 43   
  */
 44   
 public interface Translator
 45   
 {
 46   
     /**
 47   
      * Invoked by a {@link org.apache.hivemind.schema.Rule} 
 48   
      * to translate an inputValue into an appropriate object.
 49   
      * Substitution symbols will already have been expanded before this method is
 50   
      * invoked.
 51   
      * 
 52   
      * @param contributingModule the module from which the input value originates
 53   
      * @param propertyType the type of the property to be assigned by this translator; smart translators may
 54   
      * be able to automatically convert from string to the correct type
 55   
      * @param inputValue the value to be translated, either an attribute value or the content of the element
 56   
      * @param location the location of the inputValue; used to set the location of created objects,
 57   
      * or when reporting errors
 58   
      */
 59   
     public Object translate(
 60   
         Module contributingModule,
 61   
         Class propertyType,
 62   
         String inputValue,
 63   
         Location location);
 64   
 }
 65