Hi,
I'm not sure if it is resonable to mix up COSNames with a special meaning and
simple COSStrings. Can you explain what exactly your are trying to do?
I will give you an example. When I want to read the alternate color
space name of a DeviceN color space I have to write something like
public String getAlternateColorSpaceName()
{
COSBase alternate = array.getObject( 2 );
if ( alternate instanceof COSName )
return ((COSName) alternate).getName();
else if ( alternate instanceof COSString )
return ((COSString) alternate).getString();
else if ( alternate instanceof COSArray ) {
COSArray altCsArr = (COSArray) alternate;
String csName = altCsArr.getName(0);
if ( csName == null )
// maybe a string object
csName = altCsArr.getString(0);
return csName;
}
log.error( "Unexpected object type for alternate color
space name: " + alternate.getClass().getSimpleName() );
return "";
}
It might be the case that normally such names should be COSName objects
but most objects (color space objects etc.) allow the user to set such
names while creating/manipulating a PDF document and typically accept a
COSBase object. Thus the user might add the name as a COSString. In the
end I have to test all possible object types in order to read the
string. Thus if there would be an interface with a common getStringValue
method we could reduce some code overhead. Furthermore since reading
names like in the example given is quite common when dealing with color
spaces it would be helpful to have a utilities class containing a method
returning the first string object from a COSBase (for COSName,
COSString, COSArray).
Kind regards,
Timo Boehme
--
Timo Boehme
OntoChem GmbH
H.-Damerow-Str. 4
06120 Halle/Saale
T: +49 345 4780472
F: +49 345 4780471
timo.boe...@ontochem.com
_____________________________________________________________________
OntoChem GmbH
Geschäftsführer: Dr. Lutz Weber
Sitz: Halle / Saale
Registergericht: Stendal
Registernummer: HRB 215461
_____________________________________________________________________