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

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 TemplateContextType

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

public class TemplateContextType
extends Object

A context type defines a context within which templates are resolved. It stores a number of TemplateVariableResolvers. A TemplateBuffer can be resolved in a TemplateContext using the resolve(TemplateBuffer, TemplateContext) method.

Clients may extend this class.

Since:
3.0

Constructor Summary
TemplateContextType ()
          Creates a context type with a null identifier.
TemplateContextType ( String id)
          Creates a context type with an identifier.
TemplateContextType ( String id, String name)
          Creates a context type with an identifier.
 
Method Summary
 void addResolver ( TemplateVariableResolver resolver)
          Adds a variable resolver to the context type.
  String getId ()
          Returns the id of the context type.
  String getName ()
          Returns the name of the context type.
protected   TemplateVariableResolver getResolver ( String type)
          Returns the resolver for the given type.
 void removeAllResolvers ()
          Removes all template variables from the context type.
 void removeResolver ( TemplateVariableResolver resolver)
          Removes a template variable from the context type.
 void resolve ( TemplateBuffer buffer, TemplateContext context)
          Resolves the variables in buffer within context and edits the template buffer to reflect the resolved variables.
 void resolve ( TemplateVariable variable, TemplateContext context)
          Resolves a single variable in a context.
  Iterator resolvers ()
          Returns an iterator for the variables known to the context type.
 void setId ( String id)
          Sets the id of this context.
 void setName ( String name)
          Sets the name of the context type.
 void validate ( String pattern)
          Validates a pattern, a TemplateException is thrown if validation fails.
protected  void validateVariables ( TemplateVariable[] variables)
          Validates the variables in this context type.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateContextType

public TemplateContextType(
String id)
Creates a context type with an identifier. The identifier must be unique, a qualified name is suggested. The id is also used as name.

Parameters:
id - the unique identifier of the context type

TemplateContextType

public TemplateContextType(
String id,
                           
String name)
Creates a context type with an identifier. The identifier must be unique, a qualified name is suggested.

Parameters:
id - the unique identifier of the context type
name - the name of the context type

TemplateContextType

public TemplateContextType()
Creates a context type with a null identifier.

This is a framework-only constructor that exists only so that context types can be contributed via an extension point and that should not be called in client code except for subclass constructors; use TemplateContextType(String) instead.

Method Detail

getId

public 
String getId()
Returns the id of the context type.

Returns:
the id of the receiver

getName

public 
String getName()
Returns the name of the context type.

Returns:
the name of the context type

setId

public final void setId(
String id)
                 throws 
RuntimeException
Sets the id of this context.

This is a framework-only method that exists solely so that context types can be contributed via an extension point and that should not be called in client code; use TemplateContextType(String) instead.

Parameters:
id - the identifier of this context
Throws:
RuntimeException - an unspecified exception if the id has already been set on this context type

setName

public final void setName(
String name)
Sets the name of the context type.

This is a framework-only method that exists solely so that context types can be contributed via an extension point and that should not be called in client code; use TemplateContextType(String, String) instead.

Parameters:
name - the name of the context type

addResolver

public void addResolver(
TemplateVariableResolver resolver)
Adds a variable resolver to the context type. If there already is a resolver for the same type, the previous one gets replaced by resolver.

Parameters:
resolver - the resolver to be added under its name

removeResolver

public void removeResolver(
TemplateVariableResolver resolver)
Removes a template variable from the context type.

Parameters:
resolver - the variable to be removed

removeAllResolvers

public void removeAllResolvers()
Removes all template variables from the context type.


resolvers

public 
Iterator resolvers()
Returns an iterator for the variables known to the context type.

Returns:
an iterator over the variables in this context type

getResolver

protected 
TemplateVariableResolver getResolver(
String type)
Returns the resolver for the given type.

Parameters:
type - the type for which a resolver is needed
Returns:
a resolver for the given type, or null if none is registered

validate

public void validate(
String pattern)
              throws 
TemplateException
Validates a pattern, a TemplateException is thrown if validation fails.

Parameters:
pattern - the template pattern to validate
Throws:
TemplateException - if the pattern is invalid

validateVariables

protected void validateVariables(
TemplateVariable[] variables)
                          throws 
TemplateException
Validates the variables in this context type. If a variable is not valid, e.g. if its type is not known in this context type, a TemplateException is thrown.

The default implementation does nothing.

Parameters:
variables - the variables to validate
Throws:
TemplateException - if one of the variables is not valid in this context type

resolve

public void resolve(
TemplateBuffer buffer,
                    
TemplateContext context)
             throws 
MalformedTreeException,
                    
BadLocationException
Resolves the variables in buffer within context and edits the template buffer to reflect the resolved variables.

Parameters:
buffer - the template buffer
context - the template context
Throws:
MalformedTreeException - if the positions in the buffer overlap
BadLocationException - if the buffer cannot be successfully modified

resolve

public void resolve(
TemplateVariable variable,
                    
TemplateContext context)
Resolves a single variable in a context. Resolving is delegated to the registered resolver.

Parameters:
variable - the variable to resolve
context - the context in which to resolve the variable
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