*
* @throws IOException If there is an error getting the alternate color spaces.
*/
public List getAlternateColorSpaces() throws IOException
{
COSBase alternate = stream.getStream().getDictionaryObject( COSName.getPDFName( "Alternate" ) );
COSArray alternateArray = null;
if( alternate == null )
{
alternateArray = new COSArray();
int numComponents = getNumberOfComponents();
String csName = null;
if( numComponents == 1 )
{
csName = PDDeviceGray.NAME;
}
else if( numComponents == 3 )
{
csName = PDDeviceRGB.NAME;
}
else if( numComponents == 4 )
{
csName = PDDeviceCMYK.NAME;
}
else
{
throw new IOException( "Unknown colorspace number of components:" + numComponents );
}
alternateArray.add( COSName.getPDFName( csName ) );
}
else
{
if( alternate instanceof COSArray )
{
alternateArray = (COSArray)alternate;
}
else if( alternate instanceof COSName )
{
alternateArray = new COSArray();
alternateArray.add( alternate );
}
else
{
throw new IOException( "Error: expected COSArray or COSName and not " +
alternate.getClass().getName() );
}
}
List retval = new ArrayList();
for( int i=0; i<alternateArray.size(); i++ )
{