Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.text.templates
Class TemplateTranslator


java.lang.Object
  extended by 
org.eclipse.jface.text.templates.TemplateTranslator

public class TemplateTranslator
extends Object

The template translator translates a string into a template buffer. Regions marked as variables are translated into TemplateVariables.

The EBNF grammar of a valid string is as follows:

 template := (text | escape)*.
 text := character - dollar.
 escape := dollar ('{' variable '}' | dollar).
 dollar := '$'.
 variable := identifier | identifier ':' type.
 type := qualifiedname | qualifiedname '(' arguments ')'.
 arguments := (argument ',')* argument.
 argument := qualifiedname | argumenttext.
 qualifiedname := (identifier '.')* identifier.
 argumenttext := "'" (character - "'" | "'" "'")* "'".

Clients may only replace the createVariable method of this class.

Since:
3.0

Constructor Summary
TemplateTranslator ()
           
 
Method Summary
protected   TemplateVariable createVariable ( String type, String name, int[] offsets)
          Deprecated. as of 3.3 use createVariable(TemplateVariableType, String, int[]) instead
protected   TemplateVariable createVariable ( TemplateVariableType type, String name, int[] offsets)
          Hook method to create new variables.
  String getErrorMessage ()
          Returns an error message if an error occurred for the last translation, null otherwise.
  TemplateBuffer translate ( String string)
          Translates a template string to TemplateBuffer.
  TemplateBuffer translate ( Template template)
          Translates a template to a TemplateBuffer.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateTranslator

public TemplateTranslator()
Method Detail

getErrorMessage

public 
String getErrorMessage()
Returns an error message if an error occurred for the last translation, null otherwise.

Returns:
the error message if an error occurred during the most recent translation, null otherwise

translate

public 
TemplateBuffer translate(
Template template)
                         throws 
TemplateException
Translates a template to a TemplateBuffer. null is returned if there was an error. getErrorMessage() retrieves the associated error message.

Parameters:
template - the template to translate.
Returns:
returns the template buffer corresponding to the string
Throws:
TemplateException - if translation failed
See Also:
getErrorMessage()

translate

public 
TemplateBuffer translate(
String string)
                         throws 
TemplateException
Translates a template string to TemplateBuffer. null is returned if there was an error. getErrorMessage() retrieves the associated error message.

Parameters:
string - the string to translate.
Returns:
returns the template buffer corresponding to the string
Throws:
TemplateException - if translation failed
See Also:
getErrorMessage()

createVariable

protected 
TemplateVariable createVariable(
String type,
                                          
String name,
                                          int[] offsets)
Deprecated. as of 3.3 use createVariable(TemplateVariableType, String, int[]) instead

Hook method to create new variables. Subclasses may override to supply their custom variable type.

Clients may replace this method.

Parameters:
type - the type of the new variable.
name - the name of the new variable.
offsets - the offsets where the variable occurs in the template
Returns:
a new instance of TemplateVariable

createVariable

protected 
TemplateVariable createVariable(
TemplateVariableType type,
                                          
String name,
                                          int[] offsets)
Hook method to create new variables. Subclasses may override to supply their custom variable type.

Clients may replace this method.

Parameters:
type - the type of the new variable.
name - the name of the new variable.
offsets - the offsets where the variable occurs in the template
Returns:
a new instance of TemplateVariable
Since:
3.3

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire