Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (C) 2006-2015 phloc systems
* http://www.phloc.com
* office[at]phloc[dot]com
*
* 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 com.phloc.commons.collections.attrs;
import java.io.Serializable;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.phloc.commons.annotations.ReturnsMutableCopy;
/**
* Base interface for a generic read-only attribute container. It maps strings
* to any Java object.
*
* @author Philip Helger
*/
public interface IReadonlyAttributeContainer extends Serializable
{
/**
* @return The number of contained attributes. Always ≥ 0.
*/
@Nonnegative
int getAttributeCount ();
/**
* @return true if this attribute container does not contain any
* attribute at all, false if at least one attribute is
* contained.
*/
boolean containsNoAttribute ();
/**
* Check if an attribute of the given name is contained.
*
* @param sName
* name of the attribute to check
* @return true if the attribute is contained, false
* otherwise
*/
boolean containsAttribute (@Nullable String sName);
/**
* @return The non-null map with all contained attributes.
*/
@Nonnull
@ReturnsMutableCopy
Map getAllAttributes ();
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @return null if no such value exists
*/
@Nullable
Object getAttributeObject (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name. If the type
* of the attribute in the scope does not match, a
* {@link java.lang.ClassCastException} is thrown! If you just want to
* retrieve a String, use {@link #getAttributeAsString(String)}!
* This call is identical to the call
* getCastedAttribute(sName, null)
*
* @param
* return type
* @param sName
* the attribute name
* @return null if no such value exists
*/
@Nullable
DATATYPE getCastedAttribute (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name. If the type
* of the attribute in the scope does not match, a
* {@link java.lang.ClassCastException} is thrown! If you just want to
* retrieve a String, use {@link #getAttributeAsString(String, String)}!
*
* @param
* return type
* @param sName
* The attribute name.
* @param aDefault
* The default value to be returned if no such attribute exists
* @return The passed default value if no such attribute exists
*/
@Nullable
DATATYPE getCastedAttribute (@Nullable String sName, @Nullable DATATYPE aDefault);
/**
* Get the attribute value associated to the given attribute name. If the type
* of the attribute in the scope does not match, the TypeConverter is invoked!
* If you just want to retrieve a String, use
* {@link #getAttributeAsString(String)}!
* This call is identical to the call
* getTypedAttribute(sName, null)
*
* @param
* return type
* @param sName
* the attribute name
* @param aDstClass
* The destination class to convert to. May not be null.
* @return null if no such value exists
*/
@Nullable
DATATYPE getTypedAttribute (@Nullable String sName, @Nonnull Class aDstClass);
/**
* Get the attribute value associated to the given attribute name. If the type
* of the attribute in the scope does not match, the TypeConverter is invoked!
* If you just want to retrieve a String, use
* {@link #getAttributeAsString(String, String)}!
*
* @param
* return type
* @param sName
* The attribute name.
* @param aDstClass
* The destination class to convert to. May not be null.
* @param aDefault
* The default value to be returned if no such attribute exists
* @return The passed default value if no such attribute exists
*/
@Nullable
DATATYPE getTypedAttribute (@Nullable String sName,
@Nonnull Class aDstClass,
@Nullable DATATYPE aDefault);
/**
* Get the attribute value associated to the given attribute name.
* This is a shortcut for the following call:
* getAttributeAsString (sName, null)
*
* @param sName
* the attribute name
* @return The attribute value or null if no such attribute
* exists
*/
@Nullable
String getAttributeAsString (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name or the
* passed default value if no such attribute is present.
*
* @param sName
* the attribute name
* @param sDefault
* The default value to be returned, if the passed attribute name is
* unknown
* @return The attribute value or sDefault if no such attribute
* exists
*/
@Nullable
String getAttributeAsString (@Nullable String sName, @Nullable String sDefault);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @return The attribute value or
* {@link com.phloc.commons.CGlobal#ILLEGAL_UINT} if no such attribute
* exists
*/
int getAttributeAsInt (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @param nDefault
* the default value to be returned if the value is not present
* @return The attribute value or nDefault if no such attribute
* exists
*/
int getAttributeAsInt (@Nullable String sName, int nDefault);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @return The attribute value or
* {@link com.phloc.commons.CGlobal#ILLEGAL_ULONG} if no such
* attribute exists
*/
long getAttributeAsLong (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @param nDefault
* the default value to be returned if the value is not present
* @return The attribute value or nDefault if no such attribute
* exists
*/
long getAttributeAsLong (@Nullable String sName, long nDefault);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @return The attribute value or
* {@link com.phloc.commons.CGlobal#ILLEGAL_UINT} if no such attribute
* exists
*/
double getAttributeAsDouble (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @param dDefault
* the default value to be returned if the value is not present
* @return The attribute value or nDefault if no such attribute
* exists
*/
double getAttributeAsDouble (@Nullable String sName, double dDefault);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @return The attribute value or false if no such attribute
* exists
*/
boolean getAttributeAsBoolean (@Nullable String sName);
/**
* Get the attribute value associated to the given attribute name.
*
* @param sName
* the attribute name
* @param bDefault
* the default value to be returned if the value is not present
* @return The attribute value or bDefault if no such attribute
* exists
*/
boolean getAttributeAsBoolean (@Nullable String sName, boolean bDefault);
/**
* Get an enumerator over all contained attribute names.
*
* @return an Enumerator over all attribute names
*/
@Nonnull
Enumeration getAttributeNames ();
/**
* @return A non-null set of all attribute names.
*/
@Nonnull
Set getAllAttributeNames ();
/**
* @return A non-null collection of all attribute values.
*/
@Nonnull
Collection