001: /*
002: Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004: Contributors:
005: * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006: contributed code is Copyright © 2006 by Stefano Chizzolini.
007:
008: This file should be part of the source code distribution of "PDF Clown library"
009: (the Program): see the accompanying README files for more info.
010:
011: This Program is free software; you can redistribute it and/or modify it under
012: the terms of the GNU General Public License as published by the Free Software
013: Foundation; either version 2 of the License, or (at your option) any later version.
014:
015: This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016: WARRANTY, either expressed or implied; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019: You should have received a copy of the GNU General Public License along with this
020: Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022: Redistribution and use, with or without modification, are permitted provided that such
023: redistributions retain the above copyright notice, license and disclaimer, along with
024: this list of conditions.
025: */
026:
027: package it.stefanochizzolini.clown.documents.contents;
028:
029: import it.stefanochizzolini.clown.documents.Document;
030: import it.stefanochizzolini.clown.documents.contents.xObjects.XObject;
031: import it.stefanochizzolini.clown.objects.PdfDictionary;
032: import it.stefanochizzolini.clown.objects.PdfDirectObject;
033: import it.stefanochizzolini.clown.objects.PdfIndirectObject;
034: import it.stefanochizzolini.clown.objects.PdfName;
035: import it.stefanochizzolini.clown.objects.PdfObjectWrapper;
036: import it.stefanochizzolini.clown.objects.PdfReference;
037: import it.stefanochizzolini.clown.util.NotImplementedException;
038:
039: import java.util.ArrayList;
040: import java.util.Collection;
041: import java.util.Map;
042: import java.util.Set;
043:
044: /**
045: External objects collection [PDF:1.6:3.7.2].
046: */
047: public class XObjects extends PdfObjectWrapper<PdfDictionary> implements
048: Map<PdfName, XObject> {
049: // <class>
050: // <dynamic>
051: // <constructors>
052: public XObjects(Document context) {
053: super (context.getFile(), new PdfDictionary());
054: }
055:
056: XObjects(PdfDirectObject baseObject, PdfIndirectObject container) {
057: super (baseObject, container);
058: }
059:
060: // </constructors>
061:
062: // <interface>
063: // <public>
064: @Override
065: public XObjects clone(Document context) {
066: throw new NotImplementedException();
067: }
068:
069: /**
070: Gets the key associated to a given value.
071: */
072: public PdfName getKey(XObject value) {
073: return getBaseDataObject().getKey(value.getBaseObject());
074: }
075:
076: // <Map>
077: public void clear() {
078: getBaseDataObject().clear();
079: }
080:
081: public boolean containsKey(Object key) {
082: return getBaseDataObject().containsKey(key);
083: }
084:
085: public boolean containsValue(Object value) {
086: return getBaseDataObject().containsValue(
087: ((XObject) value).getBaseObject());
088: }
089:
090: public Set<Map.Entry<PdfName, XObject>> entrySet() {
091: throw new NotImplementedException();
092: }
093:
094: public boolean equals(PdfDirectObject object) {
095: throw new NotImplementedException();
096: }
097:
098: public XObject get(Object key) {
099: return XObject
100: .wrap((PdfReference) getBaseDataObject().get(key));
101: }
102:
103: public int hashCode() {
104: throw new NotImplementedException();
105: }
106:
107: public boolean isEmpty() {
108: return getBaseDataObject().isEmpty();
109: }
110:
111: public Set<PdfName> keySet() {
112: return getBaseDataObject().keySet();
113: }
114:
115: public XObject put(PdfName key, XObject value) {
116: return XObject.wrap((PdfReference) getBaseDataObject().put(key,
117: value.getBaseObject()));
118: }
119:
120: public void putAll(Map<? extends PdfName, ? extends XObject> entries) {
121: throw new NotImplementedException();
122: }
123:
124: public XObject remove(Object key) {
125: return XObject.wrap((PdfReference) getBaseDataObject().remove(
126: key));
127: }
128:
129: public int size() {
130: return getBaseDataObject().size();
131: }
132:
133: public Collection<XObject> values() {
134: /*
135: NOTE: We have to encapsulate raw objects into XObject-derived ones.
136: */
137: // Get the raw objects!
138: Collection<PdfDirectObject> objects = getBaseDataObject()
139: .values();
140: // Get room for the corresponding Font collection!
141: Collection<XObject> values = new ArrayList<XObject>(objects
142: .size());
143: // Populating the collection...
144: for (PdfDirectObject object : objects) {
145: values.add(XObject.wrap((PdfReference) object));
146: }
147:
148: return values;
149: }
150: // </Map>
151: // </public>
152: // </interface>
153: // </dynamic>
154: // </class>
155: }
|