1package org.apache.archiva.metadata.model;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import java.util.Properties;
2324/**25 * Metadata on project level.26 * Namely the namespace and the project id. But different repository types may27 * add additional metadata information.28 *29 */30publicclassProjectMetadata31 {
32private Properties customProperties;
3334private String namespace;
3536private String id;
3738/**39 * Sets the project id.40 * @param id41 */42publicvoid setId( String id )
43 {
44this.id = id;
45 }
4647/**48 * Returns the project id.49 * @return50 */51public String getId()
52 {
53return id;
54 }
5556/**57 * Returns the namespace where the project resides.58 * @return The namespace.59 */60public String getNamespace()
61 {
62return namespace;
63 }
6465/**66 * Sets the namespace. Namespaces are strings that may contain '.' characters to separate67 * the hierarchy levels.68 * @return69 */70publicvoid setNamespace( String namespace )
71 {
72this.namespace = namespace;
73 }
7475/**76 * Adds a custom property. Repository storage implementations may add custom properties77 * on the project level.78 * @param key79 * @param value80 */81publicvoid addProperty(String key, String value) {
82 Properties props = getProperties();
83 props.setProperty( key, value );
84 }
8586/**87 * Replaces all custom properties with the given properties object.88 * The given object is stored by reference and not copied.89 * @param properties90 */91publicvoid setProperties(Properties properties) {
92this.customProperties = properties;
93 }
949596/**97 * Returns the object with all custom properties.98 * If there are no custom properties set, a empty object will be returned.99 *100 * @return The custom properties.101 */102public Properties getProperties() {
103if (customProperties==null)
104 {
105 Properties props = new Properties( );
106this.customProperties = props;
107return props;
108 } else {
109returnthis.customProperties;
110 }
111 }
112113/**114 * Returns true, if there are custom properties set.115 * @return True, if there exist custom properties.116 */117publicboolean hasProperties() {
118returnthis.customProperties != null && this.customProperties.size()>0;
119 }
120121 @Override
122public String toString()
123 {
124final StringBuilder sb = new StringBuilder( "ProjectMetadata{" );
125 sb.append( "namespace='" ).append( namespace ).append( '\'' );
126 sb.append( ", id='" ).append( id ).append( '\'' );
127if (customProperties!=null) {
128 sb.append(", custom: '").append(customProperties.toString()).append('\'');
129 }
130 sb.append( '}' );
131return sb.toString();
132 }
133134135 }