com.topcoder.shared.language
Class BaseLanguage

java.lang.Object
  |
  +--com.topcoder.shared.language.BaseLanguage
All Implemented Interfaces:
java.lang.Cloneable, com.topcoder.shared.netCommon.CustomSerializable, Language, java.io.Serializable
Direct Known Subclasses:
CStyleLanguage

public abstract class BaseLanguage
extends java.lang.Object
implements Language

The BaseLanguage class is the implementation of all the semantics associated with a supported programming language. This basically consists of the logic for generating language-dependent method signatures. An instance of type Language also servers as a convenient identifier for a particular language.

Author:
Logan Hanks
See Also:
DataType, Serialized Form

Constructor Summary
BaseLanguage()
          Empty constructor
BaseLanguage(int id, java.lang.String name)
          Constructs a language with the specified id and descriptor.
 
Method Summary
 void customReadObject(com.topcoder.shared.netCommon.CSReader reader)
          Custom serialization.
 void customWriteObject(com.topcoder.shared.netCommon.CSWriter writer)
          Custom serialization.
 boolean equals(java.lang.Object o)
          Two languages are equal if they have the same identifier.
 int getId()
          Returns the unique language identifier.
static Language getLanguage(int typeID)
          Helper method to return a Language for the identifier.
abstract  java.lang.String getMethodSignature(java.lang.String methodName, DataType returnType, DataType[] paramTypes, java.lang.String[] paramNames)
          Dependents of this class should implement the getMethodSignature.
 java.lang.String getName()
          Returns the language descriptor (or name) such as "Java" or "C++".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseLanguage

public BaseLanguage()
Empty constructor


BaseLanguage

public BaseLanguage(int id,
                    java.lang.String name)
Constructs a language with the specified id and descriptor.

Parameters:
id - the identifier of the language.
name - the descriptor of the language.
Method Detail

getId

public int getId()
Returns the unique language identifier.

Specified by:
getId in interface Language
Returns:
the unique language identifier.

getName

public java.lang.String getName()
Returns the language descriptor (or name) such as "Java" or "C++".

Specified by:
getName in interface Language
Returns:
the language descriptor (or name) such as "Java" or "C++".

equals

public boolean equals(java.lang.Object o)
Two languages are equal if they have the same identifier.

Specified by:
equals in interface Language
Overrides:
equals in class java.lang.Object
Returns:
true if the passed object is not null, of type Language and whose language identifier matches.

customWriteObject

public void customWriteObject(com.topcoder.shared.netCommon.CSWriter writer)
                       throws java.io.IOException
Custom serialization.

Specified by:
customWriteObject in interface Language
Parameters:
writer - the writer to write to.
Throws:
java.io.IOException - if an I/O error has occurred in the stream that backs the writer.

customReadObject

public void customReadObject(com.topcoder.shared.netCommon.CSReader reader)
                      throws java.io.IOException,
                             java.io.ObjectStreamException
Custom serialization.

Specified by:
customReadObject in interface Language
Parameters:
reader - the reader to read from.
Throws:
java.io.ObjectStreamException - if the information that is read is inconsistent (stream corrupted or incompatibility between writers and readers)
java.io.IOException - if an I/O error has occurred in the stream that backs the reader.

getMethodSignature

public abstract java.lang.String getMethodSignature(java.lang.String methodName,
                                                    DataType returnType,
                                                    DataType[] paramTypes,
                                                    java.lang.String[] paramNames)
Dependents of this class should implement the getMethodSignature.

Specified by:
getMethodSignature in interface Language
Parameters:
methodName - the name of the method.
returnType - the datatype that will be returned by the method.
paramTypes - the datatype of the parameters of the method.
paramNames - the name of parameters of the method.
Returns:
the formatted method signature specific to the language.
See Also:
Language.getMethodSignature(String, DataType, DataType[], String[])

getLanguage

public static Language getLanguage(int typeID)
Helper method to return a Language for the identifier.

Parameters:
typeID - the language identifier.
Returns:
the Language for the identifer.
Throws:
java.lang.IllegalArgumentException - of typeID is unknown.