/* * Copyright 2008 National Library of Sweden * * Licensed 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. */ package se.kb.oai.ore; import java.net.URI; import java.util.LinkedList; import java.util.List; import org.dom4j.QName; /** * Abstract base class for those classes that make up an aggregation, i.e. * Aggregation and AggregatedResource. It can be used to * get and set Types and Metadata. * * @author Oskar Grenholm, National Library of Sweden */ public abstract class AggregateBase { protected URI id; protected List types; protected List metadata; /** * Creates an AggregateBase with the specified id. * * @param id the id */ public AggregateBase(URI id) { this.id = id; this.types = new LinkedList(); this.metadata = new LinkedList(); } /** * Get the id. * * @return the id */ public URI getId() { return id; } /** * Set the id. * * @param id the id */ public void setId(URI id) { this.id = id; } /** * Get all types associated with this object. * * @return a list of types */ public List getTypes() { return types; } /** * Set the types associated with this object. * * @param types a list of types */ public void setTypes(List types) { this.types = types; } /** * Add a Type to this object. * * @param type a type */ public void addType(Type type) { types.add(type); } /** * Get a list of all the Metadata for this object. * * @return a list with metadata */ public List getMetadata() { return metadata; } /** * Get a list of only the Metadata that matches * the qualified name for this object. * * @param name a qualified name * * @return a list with metadata */ public List getMetadata(QName name) { List list = new LinkedList(); for (Metadata meta : metadata) { if (meta.getName().equals(name)) { list.add(meta); } } return list; } /** * Set the metadata for this object. * * @param metadata a list with metadata */ public void setMetadata(List metadata) { this.metadata = metadata; } /** * Add a Metadata to the list of metadata. * * @param meta a metadata */ public void addMetadata(Metadata meta) { metadata.add(meta); } }