// parse out sdo_geometry
Matcher sdoGeometryMatcher = sdoGeometryPattern.matcher(upperVal);
if (! sdoGeometryMatcher.find())
{
throw new TypeCastException(value, this);
}
BigDecimal gtype = NULL.equals(sdoGeometryMatcher.group(1)) ?
null : new BigDecimal(sdoGeometryMatcher.group(1));
BigDecimal srid = NULL.equals(sdoGeometryMatcher.group(2)) ?
null : new BigDecimal(sdoGeometryMatcher.group(2));
// parse out sdo_point_type
upperVal = upperVal.substring(sdoGeometryMatcher.end());
Matcher sdoPointTypeMatcher = sdoPointTypePattern.matcher(upperVal);
if (! sdoPointTypeMatcher.find())
{
throw new TypeCastException(value, this);
}
OracleSdoPointType sdoPoint;
if (NULL.equals(sdoPointTypeMatcher.group(4)))
{
sdoPoint = null;
}
else
{
sdoPoint = new OracleSdoPointType(
NULL.equals(sdoPointTypeMatcher.group(1)) ? null :
new BigDecimal(sdoPointTypeMatcher.group(1)),
NULL.equals(sdoPointTypeMatcher.group(2)) ? null :
new BigDecimal(sdoPointTypeMatcher.group(2)),
NULL.equals(sdoPointTypeMatcher.group(3)) ? null :
new BigDecimal(sdoPointTypeMatcher.group(3)));
}
// parse out sdo_elem_info_array
upperVal = upperVal.substring(sdoPointTypeMatcher.end());
Matcher sdoElemInfoArrayMatcher = sdoElemInfoArrayPattern.matcher(upperVal);
if (! sdoElemInfoArrayMatcher.find())
{
throw new TypeCastException(value, this);
}
OracleSdoElemInfoArray sdoElemInfoArray;
if (NULL.equals(sdoElemInfoArrayMatcher.group(2)))
{
sdoElemInfoArray = null;
}
else
{
String [] elemInfoStrings = sdoElemInfoArrayMatcher.group(1).
trim().split("\\s*,\\s*");
if (elemInfoStrings.length == 1 && "".equals(elemInfoStrings[0]))
{
sdoElemInfoArray = new OracleSdoElemInfoArray();
}
else
{
BigDecimal [] elemInfos = new BigDecimal[elemInfoStrings.length];
for (int index = 0; index < elemInfoStrings.length; index++)
{
elemInfos[index] = NULL.equals(elemInfoStrings[index]) ?
null : new BigDecimal(elemInfoStrings[index]);
}
sdoElemInfoArray = new OracleSdoElemInfoArray(elemInfos);
}
}
// parse out sdo_ordinate_array
upperVal = upperVal.substring(sdoElemInfoArrayMatcher.end());
Matcher sdoOrdinateArrayMatcher = sdoOrdinateArrayPattern.matcher(upperVal);
if (! sdoOrdinateArrayMatcher.find())
{
throw new TypeCastException(value, this);
}
OracleSdoOrdinateArray sdoOrdinateArray;
if (NULL.equals(sdoOrdinateArrayMatcher.group(2)))
{
sdoOrdinateArray = null;
}
else
{
String [] ordinateStrings = sdoOrdinateArrayMatcher.group(1).
trim().split("\\s*,\\s*");
if (ordinateStrings.length == 1 && "".equals(ordinateStrings[0]))
{
sdoOrdinateArray = new OracleSdoOrdinateArray();
}
else
{
BigDecimal [] ordinates = new BigDecimal[ordinateStrings.length];
for (int index = 0; index < ordinateStrings.length; index++)
{
ordinates[index] = NULL.equals(ordinateStrings[index]) ?
null : new BigDecimal(ordinateStrings[index]);
}
sdoOrdinateArray = new OracleSdoOrdinateArray(ordinates);
}
}
OracleSdoGeometry sdoGeometry = new OracleSdoGeometry(
gtype, srid, sdoPoint, sdoElemInfoArray, sdoOrdinateArray);
return sdoGeometry;
}
catch (SQLException e)
{
throw new TypeCastException(value, this, e);
}
catch (NumberFormatException e)
{
throw new TypeCastException(value, this, e);
}
}
throw new TypeCastException(value, this);
}