public FileCacheImageOutputStream(OutputStream stream, File cacheDir) throws IOException {
    if (stream == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.0A"));
    }
    os = stream;

    if (cacheDir == null || cacheDir.isDirectory()) {
      file = File.createTempFile(IIO_TEMP_FILE_PREFIX, null, cacheDir);
      file.deleteOnExit();
    } else {
      throw new IllegalArgumentException(Messages.getString("imageio.0B"));
    }

    raf = new RandomAccessFile(file, "rw");
  }
Example #2
0
  public Attr setAttributeNode(Attr newAttr) throws DOMException {
    // Check if this attribute is already in use.
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
      if (owner == this) { // Replacing an attribute node by itself has no effect
        return null;
      } else {
        throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, Messages.getString("imageio.8E"));
      }
    }

    String name = newAttr.getName();
    Attr oldAttr = getAttributeNode(name);
    if (oldAttr != null) {
      removeAttributeNode(oldAttr);
    }

    IIOMetadataAttr iioAttr;
    if (newAttr instanceof IIOMetadataAttr) {
      iioAttr = (IIOMetadataAttr) newAttr;
      iioAttr.setOwnerElement(this);
    } else {
      iioAttr = new IIOMetadataAttr(name, newAttr.getValue(), this);
    }

    attrs.list.add(iioAttr);

    return oldAttr;
  }
Example #3
0
  public Node removeChild(Node oldChild) throws DOMException {
    if (oldChild == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.62"));
    }

    IIOMetadataNode oldIIOChild = (IIOMetadataNode) oldChild;

    // Fix next and previous
    IIOMetadataNode previous = oldIIOChild.previousSibling;
    IIOMetadataNode next = oldIIOChild.nextSibling;

    if (previous != null) {
      previous.nextSibling = next;
    }
    if (next != null) {
      next.previousSibling = previous;
    }

    // Fix this node
    if (lastChild == oldIIOChild) {
      lastChild = previous;
    }
    if (firstChild == oldIIOChild) {
      firstChild = next;
    }
    nChildren--;

    // Fix old child
    oldIIOChild.parent = null;
    oldIIOChild.previousSibling = null;
    oldIIOChild.nextSibling = null;

    return oldIIOChild;
  }
Example #4
0
 @Override
 public ImageOutputStream createOutputStreamInstance(
     Object output, boolean useCache, File cacheDir) throws IOException {
   if (output instanceof RandomAccessFile) {
     return new FileImageOutputStream((RandomAccessFile) output);
   }
   throw new IllegalArgumentException(Messages.getString("imageio.87"));
 }
Example #5
0
  public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
    if (!attrs.list.remove(oldAttr)) { // Not found
      throw new DOMException(DOMException.NOT_FOUND_ERR, Messages.getString("imageio.8F"));
    }

    ((IIOMetadataAttr) oldAttr).setOwnerElement(null);

    return oldAttr;
  }
Example #6
0
  public Node insertBefore(Node newChild, Node refChild) throws DOMException {
    if (newChild == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.61"));
    }

    IIOMetadataNode newIIOChild = (IIOMetadataNode) newChild;
    IIOMetadataNode refIIOChild = (IIOMetadataNode) refChild;

    newIIOChild.parent = this;

    if (refIIOChild == null) {
      newIIOChild.nextSibling = null;
      newIIOChild.previousSibling = lastChild;

      // Fix this node
      lastChild = newIIOChild;
      if (firstChild == null) {
        firstChild = newIIOChild;
      }
    } else {
      newIIOChild.nextSibling = refIIOChild;
      newIIOChild.previousSibling = refIIOChild.previousSibling;

      // Fix this node
      if (firstChild == refIIOChild) {
        firstChild = newIIOChild;
      }

      // Fix next node
      if (refIIOChild != null) {
        refIIOChild.previousSibling = newIIOChild;
      }
    }

    // Fix prev node
    if (newIIOChild.previousSibling != null) {
      newIIOChild.previousSibling.nextSibling = newIIOChild;
    }

    nChildren++;

    return newIIOChild;
  }
Example #7
0
  public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
    if (newChild == null) {
      throw new IllegalArgumentException(Messages.getString("imageio.61"));
    }

    IIOMetadataNode newIIOChild = (IIOMetadataNode) newChild;
    IIOMetadataNode oldIIOChild = (IIOMetadataNode) oldChild;

    IIOMetadataNode next = oldIIOChild.nextSibling;
    IIOMetadataNode previous = oldIIOChild.previousSibling;

    // Fix new node
    newIIOChild.parent = this;
    newIIOChild.nextSibling = next;
    newIIOChild.previousSibling = previous;

    // Fix this node
    if (lastChild == oldIIOChild) {
      lastChild = newIIOChild;
    }
    if (firstChild == oldIIOChild) {
      firstChild = newIIOChild;
    }

    // Fix siblings
    if (next != null) {
      next.previousSibling = newIIOChild;
    }
    if (previous != null) {
      previous.nextSibling = newIIOChild;
    }

    // Fix old child
    oldIIOChild.parent = null;
    oldIIOChild.nextSibling = next;
    oldIIOChild.previousSibling = previous;

    return oldIIOChild;
  }
Example #8
0
 public boolean isDefaultNamespace(String namespaceURI) {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #9
0
 public void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
     throws DOMException {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #10
0
 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
   throw new DOMException(
       DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getString("imageio.91"));
 }
Example #11
0
 public Node setNamedItemNS(Node arg) throws DOMException {
   throw new DOMException(
       DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getString("imageio.91"));
 }
Example #12
0
 public boolean isId() {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #13
0
 public Object getUserData(String key) {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #14
0
 public Object setUserData(String key, Object data, UserDataHandler handler) {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #15
0
 public Object getFeature(String feature, String version) {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #16
0
 public TypeInfo getSchemaTypeInfo() {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #17
0
 public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #18
0
 public boolean isSameNode(Node other) {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #19
0
 public short compareDocumentPosition(Node other) throws DOMException {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
Example #20
0
 public String getBaseURI() {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }
 public MemoryCacheImageOutputStream(OutputStream stream) {
   if (stream == null) {
     throw new IllegalArgumentException(Messages.getString("imageio.0A"));
   }
   os = stream;
 }
Example #22
0
 public String lookupNamespaceURI(String prefix) {
   throw new DOMException(DOMException.NOT_SUPPORTED_ERR, Messages.getString("imageio.90"));
 }