You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2008/08/05 16:22:31 UTC
svn commit: r682720 - in /xmlgraphics/commons/trunk: ./
src/java/org/apache/xmlgraphics/image/loader/
src/java/org/apache/xmlgraphics/image/loader/impl/
src/java/org/apache/xmlgraphics/util/
test/java/org/apache/xmlgraphics/image/loader/
Author: jeremias
Date: Tue Aug 5 07:22:29 2008
New Revision: 682720
URL: http://svn.apache.org/viewvc?rev=682720&view=rev
Log:
Added RefinedImageFlavor (abstract base class) to the image loading framework for better refinement of image flavors. I've checked that backwards-compatibility is preserved (since I've changed the values of some constants in ImageFlavor).
See also: http://wiki.apache.org/xmlgraphics-fop/ImageSupport/ImageHandler
Added:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java (with props)
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java (with props)
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java (with props)
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java (with props)
xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java (with props)
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageFlavor.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageXMLDOM.java
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/MimeConstants.java
xmlgraphics/commons/trunk/status.xml
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageFlavor.java?rev=682720&r1=682719&r2=682720&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageFlavor.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageFlavor.java Tue Aug 5 07:22:29 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,8 @@
package org.apache.xmlgraphics.image.loader;
+import org.apache.xmlgraphics.util.MimeConstants;
+
/**
* The flavor of an image indicates in which form it is available. A bitmap image loaded into
* memory might be represented as a BufferedImage (indicated by ImageFlavor.BUFFERED_IMAGE).
@@ -30,24 +32,31 @@
/** An image in form of a RenderedImage instance */
public static final ImageFlavor RENDERED_IMAGE = new ImageFlavor("RenderedImage");
/** An image in form of a BufferedImage instance */
- public static final ImageFlavor BUFFERED_IMAGE = new ImageFlavor("BufferedImage");
+ public static final ImageFlavor BUFFERED_IMAGE = new SimpleRefinedImageFlavor(
+ RENDERED_IMAGE, "BufferedImage");
/** An XML-based image in form of a W3C DOM instance */
public static final ImageFlavor XML_DOM = new ImageFlavor("text/xml;form=dom");
/** An image in form of a raw PNG file/stream */
- public static final ImageFlavor RAW_PNG = new ImageFlavor("RawPNG");
+ public static final ImageFlavor RAW = new ImageFlavor("Raw");
+ /** An image in form of a raw PNG file/stream */
+ public static final ImageFlavor RAW_PNG = new MimeEnabledImageFlavor(RAW,
+ MimeConstants.MIME_PNG);
/** An image in form of a raw JPEG/JFIF file/stream */
- public static final ImageFlavor RAW_JPEG = new ImageFlavor("RawJPEG");
+ public static final ImageFlavor RAW_JPEG = new MimeEnabledImageFlavor(RAW,
+ MimeConstants.MIME_JPEG);
/** An image in form of a raw EMF (Windows Enhanced Metafile) file/stream */
- public static final ImageFlavor RAW_EMF = new ImageFlavor("RawEMF");
+ public static final ImageFlavor RAW_EMF = new MimeEnabledImageFlavor(RAW,
+ MimeConstants.MIME_EMF);
/** An image in form of a raw EPS (Encapsulated PostScript) file/stream */
- public static final ImageFlavor RAW_EPS = new ImageFlavor("RawEPS");
+ public static final ImageFlavor RAW_EPS = new MimeEnabledImageFlavor(RAW,
+ MimeConstants.MIME_EPS);
/** An image in form of a raw CCITTFax stream */
public static final ImageFlavor RAW_CCITTFAX = new ImageFlavor("RawCCITTFax");
/** An image in form of a Graphics2DImage (can be painted on a Graphics2D interface) */
public static final ImageFlavor GRAPHICS2D = new ImageFlavor("Graphics2DImage");
-
+
private String name;
-
+
/**
* Constructs a new ImageFlavor. Please reuse existing constants wherever possible!
* @param name the name of the flavor (must be unique)
@@ -55,7 +64,7 @@
public ImageFlavor(String name) {
this.name = name;
}
-
+
/**
* Returns the name of the ImageFlavor.
* @return the flavor name
@@ -64,6 +73,15 @@
return this.name;
}
+ /**
+ * Indicates whether a particular image flavor is compatible with this one.
+ * @param flavor the other image flavor
+ * @return true if the two are compatible
+ */
+ public boolean isCompatible(ImageFlavor flavor) {
+ return this.equals(flavor);
+ }
+
/** {@inheritDoc} */
public int hashCode() {
final int prime = 31;
@@ -98,5 +116,5 @@
public String toString() {
return getName();
}
-
+
}
Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java?rev=682720&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java (added)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java Tue Aug 5 07:22:29 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.loader;
+
+/**
+ * Special image flavor subclass which enables the restriction to a particular MIME type.
+ */
+public class MimeEnabledImageFlavor extends RefinedImageFlavor {
+
+ private String mime;
+
+ /**
+ * Constructs a new image flavor.
+ * @param parentFlavor the parent image flavor
+ * @param mime a MIME type refining the parent image flavor
+ */
+ public MimeEnabledImageFlavor(ImageFlavor parentFlavor, String mime) {
+ super(mime + ";" + parentFlavor.getName(), parentFlavor);
+ this.mime = mime;
+ }
+
+ /**
+ * Returns the MIME type associated with the image flavor.
+ * @return the MIME type
+ */
+ public String getMIMEType() {
+ return this.mime;
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java?rev=682720&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java (added)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java Tue Aug 5 07:22:29 2008
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.loader;
+
+/**
+ * Special image flavor subclass which enables the refinement to specific (sub-)flavors but
+ * maintaining compatibility to a parent (i.e. more general) flavor.
+ */
+public abstract class RefinedImageFlavor extends ImageFlavor {
+
+ private ImageFlavor parentFlavor;
+
+ /**
+ * Constructs a new image flavor.
+ * @param parentFlavor the parent image flavor
+ */
+ protected RefinedImageFlavor(ImageFlavor parentFlavor) {
+ this(parentFlavor.getName(), parentFlavor);
+ }
+
+ /**
+ * Constructs a new image flavor.
+ * @param parentFlavor the parent image flavor
+ * @param name the name of the flavor (must be unique)
+ */
+ protected RefinedImageFlavor(String name, ImageFlavor parentFlavor) {
+ super(name);
+ this.parentFlavor = parentFlavor;
+ }
+
+ /**
+ * Returns the associated parent image flavor.
+ * @return the parent image flavor
+ */
+ public ImageFlavor getParentFlavor() {
+ return this.parentFlavor;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isCompatible(ImageFlavor flavor) {
+ return getParentFlavor().isCompatible(flavor)
+ || super.isCompatible(flavor);
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/RefinedImageFlavor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java?rev=682720&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java (added)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java Tue Aug 5 07:22:29 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.loader;
+
+/**
+ * Simple refined image flavor implementation that just differs flavors by name but allows to
+ * specify a parent flavor.
+ */
+public class SimpleRefinedImageFlavor extends RefinedImageFlavor {
+
+ /**
+ * Main constructor.
+ * @param parentFlavor the parent image flavor
+ * @param name the name of the image flavor
+ */
+ public SimpleRefinedImageFlavor(ImageFlavor parentFlavor, String name) {
+ super(name, parentFlavor);
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/SimpleRefinedImageFlavor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java?rev=682720&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java (added)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java Tue Aug 5 07:22:29 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.loader;
+
+/**
+ * Special image flavor subclass which enables the restriction to a particular XML namespace.
+ */
+public class XMLNamespaceEnabledImageFlavor extends RefinedImageFlavor {
+
+ private String namespace;
+
+ /**
+ * Constructs a new image flavor.
+ * @param parentFlavor the parent image flavor
+ * @param namespace an XML namespace URI refining the parent image flavor
+ */
+ public XMLNamespaceEnabledImageFlavor(ImageFlavor parentFlavor, String namespace) {
+ super(parentFlavor.getName() + ";namespace=" + namespace, parentFlavor);
+ this.namespace = namespace;
+ }
+
+ /**
+ * Returns the XML namespace URI associated with the image flavor.
+ * @return the XML namespace URI
+ */
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java?rev=682720&r1=682719&r2=682720&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java Tue Aug 5 07:22:29 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,6 +28,7 @@
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.MimeEnabledImageFlavor;
/**
* This class is an implementation of the Image interface exposing an InputStream for loading the
@@ -37,7 +38,7 @@
private ImageFlavor flavor;
private InputStreamFactory streamFactory;
-
+
/**
* Main constructor.
* @param info the image info object
@@ -49,7 +50,7 @@
this.flavor = flavor;
setInputStreamFactory(streamFactory);
}
-
+
/**
* Constructor for a simple InputStream as parameter.
* @param info the image info object
@@ -59,17 +60,30 @@
public ImageRawStream(ImageInfo info, ImageFlavor flavor, InputStream in) {
this(info, flavor, new SingleStreamFactory(in));
}
-
+
/** {@inheritDoc} */
public ImageFlavor getFlavor() {
return this.flavor;
}
+ /**
+ * Returns the MIME type of the stream data.
+ * @return the MIME type
+ */
+ public String getMimeType() {
+ if (getFlavor() instanceof MimeEnabledImageFlavor) {
+ return ((MimeEnabledImageFlavor)getFlavor()).getMIMEType();
+ } else {
+ //Undetermined
+ return "application/octet-stream";
+ }
+ }
+
/** {@inheritDoc} */
public boolean isCacheable() {
return !this.streamFactory.isUsedOnceOnly();
}
-
+
/**
* Sets the InputStreamFactory to be used by this image. This method allows to replace the
* original factory.
@@ -81,7 +95,7 @@
}
this.streamFactory = factory;
}
-
+
/**
* Returns a new InputStream to access the raw image.
* @return the InputStream
@@ -89,7 +103,7 @@
public InputStream createInputStream() {
return this.streamFactory.createInputStream();
}
-
+
/**
* Writes the content of the image to an OutputStream. The OutputStream in NOT closed at the
* end.
@@ -104,7 +118,7 @@
IOUtils.closeQuietly(in);
}
}
-
+
/**
* Writes the content of the image to a File.
* @param target the file to be written
@@ -118,40 +132,43 @@
IOUtils.closeQuietly(out);
}
}
-
+
/**
* Represents a factory for InputStream objects. Make sure the class is thread-safe!
*/
public interface InputStreamFactory {
-
+
/**
* Indicates whether this factory is only usable once or many times.
* @return true if the factory can only be used once
*/
boolean isUsedOnceOnly();
-
+
/**
* Creates and returns a new InputStream.
* @return the new InputStream
*/
InputStream createInputStream();
-
+
/**
* Closes the factory and releases any resources held open during the lifetime of this
* object.
*/
void close();
-
+
}
-
+
+ /**
+ * InputStream factory that can return a pre-constructed InputStream exactly once.
+ */
private static class SingleStreamFactory implements InputStreamFactory {
-
+
private InputStream in;
-
+
public SingleStreamFactory(InputStream in) {
this.in = in;
}
-
+
public synchronized InputStream createInputStream() {
if (this.in != null) {
InputStream tempin = this.in;
@@ -175,7 +192,7 @@
protected void finalize() {
close();
}
-
+
}
-
+
}
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageXMLDOM.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageXMLDOM.java?rev=682720&r1=682719&r2=682720&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageXMLDOM.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageXMLDOM.java Tue Aug 5 07:22:29 2008
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,15 +23,17 @@
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor;
/**
* This class is an implementation of the Image interface exposing an XML DOM (W3C).
*/
public class ImageXMLDOM extends AbstractImage {
+ private ImageFlavor flavor;
private Document doc;
private String rootNamespace;
-
+
/**
* Main constructor.
* @param info the image info object
@@ -42,18 +44,32 @@
super(info);
this.doc = doc;
this.rootNamespace = rootNamespace;
+ this.flavor = new XMLNamespaceEnabledImageFlavor(ImageFlavor.XML_DOM, rootNamespace);
+ }
+
+ /**
+ * Main constructor.
+ * @param info the image info object
+ * @param doc the W3C DOM document
+ * @param flavor the image flavor
+ */
+ public ImageXMLDOM(ImageInfo info, Document doc, XMLNamespaceEnabledImageFlavor flavor) {
+ super(info);
+ this.doc = doc;
+ this.rootNamespace = flavor.getNamespace();
+ this.flavor = flavor;
}
-
+
/** {@inheritDoc} */
public ImageFlavor getFlavor() {
- return ImageFlavor.XML_DOM;
+ return this.flavor;
}
/** {@inheritDoc} */
public boolean isCacheable() {
return true;
}
-
+
/**
* Returns the contained W3C DOM document.
* @return the DOM
@@ -61,7 +77,7 @@
public Document getDocument() {
return this.doc;
}
-
+
/**
* Returns the root XML namespace of the XML document.
* @return the root namespace
@@ -69,5 +85,5 @@
public String getRootNamespace() {
return this.rootNamespace;
}
-
+
}
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/MimeConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/MimeConstants.java?rev=682720&r1=682719&r2=682720&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/MimeConstants.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/MimeConstants.java Tue Aug 5 07:22:29 2008
@@ -26,38 +26,38 @@
/** Portable Document Format */
String MIME_PDF = "application/pdf";
-
+
/** PostScript */
String MIME_POSTSCRIPT = "application/postscript";
/** Encapsulated PostScript (same MIME type as PostScript) */
String MIME_EPS = MIME_POSTSCRIPT;
-
+
/** HP's PCL */
String MIME_PCL = "application/x-pcl";
/** HP's PCL (alternative MIME type) */
String MIME_PCL_ALT = "application/vnd.hp-PCL";
-
+
/** IBM's AFP */
String MIME_AFP = "application/x-afp";
/** IBM's AFP (alternative MIME type) */
String MIME_AFP_ALT = "application/vnd.ibm.modcap";
-
+
/** Plain text */
String MIME_PLAIN_TEXT = "text/plain";
-
+
/** Rich text format */
String MIME_RTF = "application/rtf";
/** Rich text format (alternative 1) */
String MIME_RTF_ALT1 = "text/richtext";
/** Rich text format (alternative 2) */
String MIME_RTF_ALT2 = "text/rtf";
-
+
/** FrameMaker's MIF */
String MIME_MIF = "application/mif";
-
+
/** Structured Vector Graphics */
String MIME_SVG = "image/svg+xml";
-
+
/** GIF images */
String MIME_GIF = "image/gif";
/** PNG images */
@@ -66,8 +66,11 @@
String MIME_JPEG = "image/jpeg";
/** TIFF images */
String MIME_TIFF = "image/tiff";
-
+
/** Proposed but non-registered MIME type for XSL-FO */
String MIME_XSL_FO = "text/xsl";
-
+
+ /** Microsoft's Enhanced Metafile */
+ String MIME_EMF = "image/x-emf";
+
}
Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=682720&r1=682719&r2=682720&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Tue Aug 5 07:22:29 2008
@@ -40,6 +40,10 @@
</contexts>
<changes>
<release version="Trunk" date="n/a">
+ <action context="Code" dev="JM" type="add">
+ Added RefinedImageFlavor to the image loading framework for better refinement
+ of image flavors.
+ </action>
<action context="Code" dev="JM" type="fix">
Bugfix: Added missing start/endPrefixMapping() calls when serializing XMP packets.
</action>
Added: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java?rev=682720&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java (added)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java Tue Aug 5 07:22:29 2008
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.loader;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for image flavors.
+ */
+public class ImageFlavorTestCase extends TestCase {
+
+ public void testBasicFlavors() throws Exception {
+ ImageFlavor f1, f2;
+
+ f1 = ImageFlavor.RAW_JPEG;
+ f2 = ImageFlavor.RAW_PNG;
+ assertFalse(f1.equals(f2));
+
+ f1 = ImageFlavor.GRAPHICS2D;
+ f2 = new ImageFlavor(ImageFlavor.GRAPHICS2D.getName());
+ assertTrue(f1.equals(f2));
+ }
+
+ public void testRefinedFlavors() throws Exception {
+ ImageFlavor f1, f2;
+
+ f1 = ImageFlavor.RENDERED_IMAGE;
+ f2 = ImageFlavor.BUFFERED_IMAGE;
+ assertFalse(f1.equals(f2));
+ assertTrue(f2.isCompatible(f1));
+ assertFalse(f1.isCompatible(f2));
+
+ f1 = ImageFlavor.XML_DOM;
+ f2 = new XMLNamespaceEnabledImageFlavor(ImageFlavor.XML_DOM, "http://www.w3.org/2000/svg");
+ assertFalse(f1.equals(f2));
+ assertTrue(f2.isCompatible(f1));
+ assertFalse(f1.isCompatible(f2));
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/image/loader/ImageFlavorTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org