com.mapinfo.midev.util

## Class Code

- java.lang.Object
- - com.mapinfo.midev.util.Code

All Implemented Interfaces:
  Serializable

    public final class Code
    extends Object
    implements Serializable

Identifies an object with a code in a codespace. Typically used to represent a projection/coordinate system (e.g. epsg:4326) a Code may be used to represent anything. When expressed as a string a Code is composed of two parts: a codespace, followed by a colon (:), terminated by a code. The meaning of the code is defined by the codespace it is in. For example, 'epsg:4326' means WGS 84 in the epsg codespace. This class holds the codespace/code tuple in one object for ease of use.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`Code(String codeSpace, String code)` Creates a Code from the specified codeSpace and code.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `equals(Object o)`
`String` `getCode()` Returns the code of this Code.
`String` `getCodeSpace()` Returns the codespace of this Code.
`int` `hashCode()`
`static Code` `parse(String codeSpaceAndCode)` Returns the Code as parsed from the specified String.
`String` `toString()` Returns the Code as a codespace/code string.

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### Code

    public Code(String codeSpace,
                String code)

Creates a Code from the specified codeSpace and code.

Parameters:
  `codeSpace` - the codespace of the code (e.g. 'epsg').
  `code` - the code of the Code.
Throws:
  `IllegalArgumentException` - if the specified codeSpace or code is null or empty.

### Method Detail

#### getCodeSpace

    public String getCodeSpace()

Returns the codespace of this Code.

Returns:
  the codespace of this Code.

#### getCode

    public String getCode()

Returns the code of this Code.

Returns:
  the code of this Code.

#### parse

    public static Code parse(String codeSpaceAndCode)

Returns the Code as parsed from the specified String. The string must contain at least one colon (':') surrounded by non-zero characters. The codespace is to the left of the colon while the code is to the right of the colon.

Parameters:
  `codeSpaceAndCode` - the codespace/code pair as a String to parse.
Returns:
  the Code as parsed from the specified String.
Throws:
  `IllegalArgumentException` - if the specified string is null does not contain a colon does not contain characters to the left or right of the colon.

#### toString

    public String toString()

Returns the Code as a codespace/code string. The codespace and code will be separated by a colon (e.g. 'epsg:4326').

Overrides:
  `toString` in class `Object`
Returns:
  the Code as a codespace/code string. The codespace and code will be separated by a colon (e.g. 'epsg:4326').

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`