source: trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/Parts.java @ 1050

Revision 1050, 3.4 KB checked in by jharrop, 2 years ago (diff)

Renamed Package -> OpcPackage?;
Additional pptx parts.

  • Property svn:eol-style set to native
Line 
1/*
2 *  Copyright 2007-2008, Plutext Pty Ltd.
3 *   
4 *  This file is part of docx4j.
5
6    docx4j is licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18
19 */
20
21/*
22 * Portions Copyright (c) 2006, Wygwam
23 * With respect to those portions:
24 *
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without modification,
28 * are permitted provided that the following conditions are met:
29 *
30 * - Redistributions of source code must retain the above copyright notice,
31 * this list of conditions and the following disclaimer.
32 * - Redistributions in binary form must reproduce the above copyright notice,
33 * this list of conditions and the following disclaimer in the documentation and/or
34 * other materials provided with the distribution.
35 * - Neither the name of Wygwam nor the names of its contributors may be
36 * used to endorse or promote products derived from this software without
37 * specific prior written permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
40 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
44 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 */
49
50package org.docx4j.openpackaging.parts;
51
52import java.util.HashMap;
53
54import org.apache.log4j.Logger;
55import org.docx4j.openpackaging.packages.OpcPackage;
56
57/**
58 * A collection of all the parts in the package
59 *
60 * @author Jason Harrop; Julien Chable
61 * @version 0.1
62 */
63public class Parts {
64
65        private static Logger log = Logger.getLogger(Parts.class);
66
67        private HashMap<PartName, Part> parts;
68
69        public Parts() {
70                parts = new HashMap<PartName, Part>();
71        }
72
73        public void put(Part part) {
74                if (get(part.getPartName()) != null) {
75                        log.warn("Overwriting existing part " + part.getPartName());
76                }
77
78                parts.put(part.getPartName(), part);
79        }
80
81        public Part get(PartName partName) {
82                return (Part) parts.get(partName);
83        }
84
85        /**
86         * Getter method for parts
87         *
88         * @return parts - A HashMap of all parts
89         */
90        public HashMap<PartName, Part> getParts() {
91                return parts;
92        }
93
94        public void remove(PartName partName) {
95
96                if (get(partName) != null) {
97                        log.info("Deleting part " + partName);
98                        parts.remove(partName);
99                } else {
100                        log.error("Couldn't delete part " + partName
101                                        + " - nothing by that name");
102                }
103        }
104
105        // @Override
106        // public Object clone() {
107        // return super.clone();
108        // }
109
110}
Note: See TracBrowser for help on using the repository browser.