001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.lenya.cms.metadata;
019:
020: /**
021: * Generic meta data interface.
022: *
023: * @version $Id: MetaData.java 473861 2006-11-12 03:51:14Z gregor $
024: */
025: public interface MetaData {
026:
027: /**
028: * Returns the values for a certain key.
029: * @param key The key.
030: * @return An array of strings.
031: * @throws MetaDataException when something went wrong.
032: */
033: String[] getValues(String key) throws MetaDataException;
034:
035: /**
036: * Returns the first value for a certain key.
037: * @param key The key.
038: * @return A string or <code>null</code> if no value is set for this key.
039: * @throws MetaDataException if an error occurs.
040: */
041: String getFirstValue(String key) throws MetaDataException;
042:
043: /**
044: * Get all available keys.
045: * @return The keys available in this MetaData object.
046: */
047: String[] getAvailableKeys();
048:
049: /**
050: * Sets the value for a certain key. All existing values will be removed.
051: * @param key The key.
052: * @param value The value to set.
053: * @throws MetaDataException when something went wrong.
054: */
055: void setValue(String key, String value) throws MetaDataException;
056:
057: /**
058: * Addds a value for a certain key. The existing values will not be removed.
059: * @param key The key.
060: * @param value The value to add.
061: * @throws MetaDataException if there's already a value set and the element doesn't support multiple values.
062: */
063: void addValue(String key, String value) throws MetaDataException;
064:
065: /**
066: * Replace the contents of the current meta data by the contents of other.
067: * @param other The other meta data manager.
068: * @throws MetaDataException if an error occurs.
069: */
070: void replaceBy(MetaData other) throws MetaDataException;
071:
072: /**
073: * Replace the contents of the current meta data by the contents of other.
074: * All meta data is replaced, disregarding the rules given by element.getActionOnCopy().
075: * @param other The other meta data manager.
076: * @throws MetaDataException if an error occurs.
077: */
078: void forcedReplaceBy(MetaData other) throws MetaDataException;
079:
080: /**
081: * @return All keys that can be used.
082: */
083: String[] getPossibleKeys();
084:
085: /**
086: * Checks if a key represents a valid metadata attribute.
087: * @param key The key.
088: * @return A boolean value.
089: */
090: boolean isValidAttribute(String key);
091:
092: /**
093: * Get last modification date.
094: * @return last modification date
095: * @throws MetaDataException if an error occurs.
096: */
097: long getLastModified() throws MetaDataException;
098:
099: /**
100: * @return The element set this meta data object belongs to.
101: */
102: ElementSet getElementSet();
103:
104: /**
105: * Removes all values for a certain key.
106: * @param key The key.
107: * @throws MetaDataException if the key is not supported.
108: */
109: void removeAllValues(String key) throws MetaDataException;
110:
111: }
|