org.ow2.util.archive.impl.ArchiveMetadataImpl Maven / Gradle / Ivy
/**
* Copyright 2007-2012 Bull S.A.S.
*
* 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 org.ow2.util.archive.impl;
import java.util.HashMap;
import java.util.Map;
import org.ow2.util.archive.api.IArchiveMetadata;
/**
* Implementation of the metadata interface of an archive.
* The keys are all in tolower case. This is because the attributes in a
* manifest are case-insensitive
* @see java.util.jar.Attributes class
* @author Florent BENOIT
*/
public class ArchiveMetadataImpl implements IArchiveMetadata {
/**
* Map that will store the entries.
*/
private Map entries;
/**
* Default constructor.
*/
public ArchiveMetadataImpl() {
// init the map
this.entries = new HashMap();
}
/**
* Gets the value of an entry for the given name.
* @param name the name of the key to use.
* @return the value
*/
public String get(final String name) {
if (name == null) {
return null;
}
return entries.get(name.toLowerCase());
}
/**
* @return the value of the implementation version of this archive.
*/
public String getImplementationVersion() {
return entries.get(java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION.toString().toLowerCase());
}
/**
* Adds an entry into this metadata.
* @param name the name of the key to add
* @param value the value of the given key
*/
public void put(final String name, final String value) {
if (name == null) {
return;
}
entries.put(name.toLowerCase(), value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy