Package ucar.nc2
Class AttributeContainerMutable
- java.lang.Object
-
- ucar.nc2.AttributeContainerMutable
-
- All Implemented Interfaces:
Iterable<Attribute>,AttributeContainer
public class AttributeContainerMutable extends Object implements AttributeContainer
A mutable collection of Attributes.
-
-
Constructor Summary
Constructors Constructor Description AttributeContainerMutable(String name)Constructor with container name.AttributeContainerMutable(String name, Iterable<Attribute> from)Constructor with container name and list of Attributes to copy in.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAll(Iterable<Attribute> atts)Add all; replace old if has same name.AttributeaddAttribute(String name, Number value)Add Attribute; name and value must not be null.AttributeaddAttribute(String name, String value)Add Attribute; name and value must not be null.AttributeaddAttribute(Attribute att)Add new or replace old if has same namestatic AttributeContainerMutablecopyFrom(AttributeContainer from)Create mutable from immutable container.AttributefindAttribute(String name)Find an Attribute by exact match on name.doublefindAttributeDouble(String attName, double defaultValue)Find a Numeric Attribute by name (ignore case), return the double value of the Attribute.AttributefindAttributeIgnoreCase(String name)Find an Attribute by name, first doing an exact match, then ignoring case.intfindAttributeInteger(String attName, int defaultValue)Find a Numeric Attribute by name (ignore case), return the integer value of the Attribute.StringfindAttributeString(String attName, String defaultValue)Find a String Attribute by name (ignore case), return the String value of the Attribute.List<Attribute>getAttributes()Returns immutable list of attributes.StringgetName()Get the (optional) name of the AttributeContainer.booleanisEmpty()True is there are no attributes in the container.booleanremove(Attribute a)Remove an Attribute : uses the attribute hashCode to find it.booleanremoveAttribute(String attName)Remove an Attribute by name.booleanremoveAttributeIgnoreCase(String attName)Remove an Attribute by name, ignoring casevoidreplace(Attribute a, String newName)Replace an Attribute with a different name, same value.voidsetImmutable()Deprecated.do not use.voidsetName(String name)AttributeContainertoImmutable()Turn into an immutable AttributeContainer-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ucar.nc2.AttributeContainer
findAttValueIgnoreCase, hasAttribute, hasAttributeIgnoreCase, iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
AttributeContainerMutable
public AttributeContainerMutable(@Nullable String name)Constructor with container name.
-
-
Method Detail
-
copyFrom
public static AttributeContainerMutable copyFrom(@Nullable AttributeContainer from)
Create mutable from immutable container.
-
setName
public void setName(@Nullable String name)
-
getName
@Nullable public String getName()
Description copied from interface:AttributeContainerGet the (optional) name of the AttributeContainer.- Specified by:
getNamein interfaceAttributeContainer
-
setImmutable
@Deprecated public void setImmutable()
Deprecated.do not use.
-
getAttributes
public List<Attribute> getAttributes()
Description copied from interface:AttributeContainerReturns immutable list of attributes.- Specified by:
getAttributesin interfaceAttributeContainer
-
addAttribute
public Attribute addAttribute(Attribute att)
Description copied from interface:AttributeContainerAdd new or replace old if has same name- Specified by:
addAttributein interfaceAttributeContainer- Parameters:
att- add this Attribute- Returns:
- the added attribute
-
addAttribute
public Attribute addAttribute(String name, String value)
Add Attribute; name and value must not be null.
-
addAttribute
public Attribute addAttribute(String name, Number value)
Add Attribute; name and value must not be null.
-
addAll
public void addAll(Iterable<Attribute> atts)
Add all; replace old if has same name.- Specified by:
addAllin interfaceAttributeContainer
-
findAttributeString
public String findAttributeString(String attName, String defaultValue)
Description copied from interface:AttributeContainerFind a String Attribute by name (ignore case), return the String value of the Attribute.- Specified by:
findAttributeStringin interfaceAttributeContainer- Returns:
- the attribute value, or defaultValue if not found
-
findAttribute
public Attribute findAttribute(String name)
Description copied from interface:AttributeContainerFind an Attribute by exact match on name.- Specified by:
findAttributein interfaceAttributeContainer
-
findAttributeIgnoreCase
public Attribute findAttributeIgnoreCase(String name)
Description copied from interface:AttributeContainerFind an Attribute by name, first doing an exact match, then ignoring case.- Specified by:
findAttributeIgnoreCasein interfaceAttributeContainer
-
findAttributeDouble
public double findAttributeDouble(String attName, double defaultValue)
Description copied from interface:AttributeContainerFind a Numeric Attribute by name (ignore case), return the double value of the Attribute.- Specified by:
findAttributeDoublein interfaceAttributeContainer- Returns:
- the attribute value, or defaultValue if not found
-
findAttributeInteger
public int findAttributeInteger(String attName, int defaultValue)
Description copied from interface:AttributeContainerFind a Numeric Attribute by name (ignore case), return the integer value of the Attribute.- Specified by:
findAttributeIntegerin interfaceAttributeContainer- Returns:
- the attribute value, or defaultValue if not found
-
remove
public boolean remove(Attribute a)
Remove an Attribute : uses the attribute hashCode to find it.- Specified by:
removein interfaceAttributeContainer- Parameters:
a- remove this attribute- Returns:
- true if was found and removed
-
replace
public void replace(Attribute a, String newName)
Replace an Attribute with a different name, same value.- Parameters:
a- remove this attribute
-
removeAttribute
public boolean removeAttribute(String attName)
Remove an Attribute by name.- Specified by:
removeAttributein interfaceAttributeContainer- Parameters:
attName- if exists, remove this attribute- Returns:
- true if was found and removed
-
removeAttributeIgnoreCase
public boolean removeAttributeIgnoreCase(String attName)
Remove an Attribute by name, ignoring case- Specified by:
removeAttributeIgnoreCasein interfaceAttributeContainer- Parameters:
attName- if exists, remove this attribute- Returns:
- true if was found and removed
-
toImmutable
public AttributeContainer toImmutable()
Turn into an immutable AttributeContainer
-
isEmpty
public boolean isEmpty()
Description copied from interface:AttributeContainerTrue is there are no attributes in the container.- Specified by:
isEmptyin interfaceAttributeContainer
-
-