Package cz.diribet.aqdef.model
Class AqdefObjectModel
- java.lang.Object
-
- cz.diribet.aqdef.model.AqdefObjectModel
-
public class AqdefObjectModel extends Object
Object model of AQDEF content.Provides methods to
- manipulate with the content (
getXXX,putXXX,removeXXX,filterXXX) - iterate through the content
forEachXXX
Use
AqdefParserto read AQDEF content andAqdefWriterto write this object model as AQDEF content.- Author:
- Vlastimil Dolejs
- See Also:
AqdefParser,AqdefWriter
- manipulate with the content (
-
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description AqdefObjectModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancontainsCharacteristic(AqdefObjectModel.CharacteristicEntries characteristic)booleancontainsPart(AqdefObjectModel.PartEntries part)booleancontainsValue(AqdefObjectModel.ValueEntries value)voidfilterCharacteristics(AqdefObjectModel.CharacteristicPredicate predicate)Removes all characteristics that do not match the given predicate.voidfilterCharacteristics(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicOfSinglePartPredicate predicate)Removes all characteristics of the given part that do not match the given predicate.voidfilterGroups(AqdefObjectModel.GroupPredicate predicate)Removes all groups that do not match the given predicate.voidfilterGroups(AqdefObjectModel.PartEntries part, AqdefObjectModel.GroupOfSinglePartPredicate predicate)Removes all groups of the given part that do not match the given predicate.voidfilterParts(AqdefObjectModel.PartPredicate predicate)Removes all parts that do not match the given predicate.voidfilterValues(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicEntries characteristic, AqdefObjectModel.ValueOfSingleCharacteristicPredicate predicate)Removes all values of the given characteristic that do not match the given predicate.voidfilterValues(AqdefObjectModel.PartEntries part, AqdefObjectModel.ValueOfSinglePartPredicate predicate)Removes all values of the given part that do not match the given predicate.voidfilterValues(AqdefObjectModel.ValuePredicate predicate)Removes all values that do not match the given predicate.Set<CharacteristicIndex>findCharacteristicIndexesForPart(PartIndex partIndex, AqdefObjectModel.CharacteristicOfSinglePartPredicate predicate)PartIndexfindPartIndexForCharacteristic(int characteristicIndex)Finds part index to which the given characteristic index belongs.voidforEachCharacteristic(AqdefObjectModel.CharacteristicConsumer consumer)Iterates through all characteristics of all partsvoidforEachCharacteristic(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicOfSinglePartConsumer consumer)Iterates through all characteristics of the given part.voidforEachGroup(AqdefObjectModel.GroupConsumer consumer)Iterates through all logical groups of all partsvoidforEachGroup(AqdefObjectModel.PartEntries part, AqdefObjectModel.GroupOfSinglePartConsumer consumer)Iterates through all logical groups of the given part.voidforEachPart(AqdefObjectModel.PartConsumer consumer)Iterates through all partsvoidforEachValue(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicEntries characteristic, AqdefObjectModel.ValueOfSingleCharacteristicConsumer consumer)Iterates through all values of the given characteristic.voidforEachValue(AqdefObjectModel.PartEntries part, AqdefObjectModel.ValueOfSinglePartConsumer consumer)Iterates through all values of the given part.voidforEachValue(AqdefObjectModel.ValueConsumer consumer)Iterates through all values.ObjectgetAnyValueOf(KKey key)Finds value of the given K-key from any part / characteristic / value.intgetCharacteristicCount()Returns total number of characteristics of all parts in this object modelAqdefObjectModel.CharacteristicEntriesgetCharacteristicEntries(int partIndex, int characteristicIndex)AqdefObjectModel.CharacteristicEntriesgetCharacteristicEntries(CharacteristicIndex characteristicIndex)List<CharacteristicIndex>getCharacteristicIndexes(PartIndex partIndex)Returns indexes of all characteristics of a part with the given index.List<AqdefObjectModel.CharacteristicEntries>getCharacteristics(PartIndex partIndex)Returns all the characteristics of a part with the given index.List<AqdefObjectModel.CharacteristicEntries>getChildCharacteristics(CharacteristicIndex characteristicIndex)Returns all child characteristics of the characteristic with the given index.List<AqdefObjectModel.CharacteristicEntries>getChildCharacteristics(GroupIndex groupIndex)Returns all child characteristics of the characteristic with the given index.List<AqdefObjectModel.GroupEntries>getChildGroups(CharacteristicIndex characteristicIndex)Returns all child groups of the characteristic with the given index.List<AqdefObjectModel.GroupEntries>getChildGroups(GroupIndex groupIndex)Returns all child groups of the characteristic with the given index.AqdefObjectModel.GroupEntriesgetGroupEntries(GroupIndex groupIndex)List<AqdefObjectModel.GroupEntries>getGroups(PartIndex partIndex)Returns all the groups of a part with the given index.AqdefObjectModel.PartEntriesgetPartEntries(int index)AqdefObjectModel.PartEntriesgetPartEntries(PartIndex index)List<PartIndex>getPartIndexes()Returns indexes of all parts in this object model.List<AqdefObjectModel.PartEntries>getParts()List<AqdefObjectModel.CharacteristicEntries>getRootCharacteristics(PartIndex partIndex)Returns all the characteristics of a part with the given index that are root of characteristic hierarchy (has no parent characteristics).List<AqdefObjectModel.GroupEntries>getRootGroups(PartIndex partIndex)Returns all the groups of a part with the given index that are root of group hierarchy (has no parent group).intgetValueCount()Returns total number of values of all parts and characteristics in this object modelAqdefObjectModel.ValueEntriesgetValueEntries(int partIndex, int characteristicIndex, int valueIndex)List<AqdefObjectModel.ValueEntries>getValueEntries(CharacteristicIndex characteristicIndex)Deprecated.usegetValues(CharacteristicIndex)insteadAqdefObjectModel.ValueEntriesgetValueEntries(ValueIndex valueIndex)List<ValueIndex>getValueIndexes()Returns indexes of all values in this object model.List<ValueIndex>getValueIndexes(CharacteristicIndex characteristicIndex)Returns indexes of all values of a characteristics with the given index.List<AqdefObjectModel.ValueEntries>getValues()List<AqdefObjectModel.ValueEntries>getValues(CharacteristicIndex characteristicIndex)List<AqdefObjectModel.ValueSet>getValueSets(PartIndex partIndex)voidnormalize()Normalize the AQDEF content.voidputCharacteristicEntries(AqdefObjectModel.CharacteristicEntries newCharacteristicEntries)voidputCharacteristicEntry(KKey key, CharacteristicIndex characteristicIndex, Object value)voidputGroupEntry(KKey key, GroupIndex groupIndex, Object value)voidputHierarchyEntry(KKey kKey, Integer nodeIndex, Object value)voidputPartEntries(AqdefObjectModel.PartEntries newPartEntries)voidputPartEntry(KKey key, PartIndex index, Object value)voidputValueEntries(AqdefObjectModel.ValueEntries newValueEntries)voidputValueEntry(KKey key, ValueIndex valueIndex, Object value)
-
-
-
Method Detail
-
putPartEntries
public void putPartEntries(AqdefObjectModel.PartEntries newPartEntries)
-
putCharacteristicEntry
public void putCharacteristicEntry(KKey key, CharacteristicIndex characteristicIndex, Object value)
-
putCharacteristicEntries
public void putCharacteristicEntries(AqdefObjectModel.CharacteristicEntries newCharacteristicEntries)
-
putGroupEntry
public void putGroupEntry(KKey key, GroupIndex groupIndex, Object value)
-
putValueEntry
public void putValueEntry(KKey key, ValueIndex valueIndex, Object value)
-
putValueEntries
public void putValueEntries(AqdefObjectModel.ValueEntries newValueEntries)
-
getPartIndexes
public List<PartIndex> getPartIndexes()
Returns indexes of all parts in this object model.- Returns:
-
getPartEntries
public AqdefObjectModel.PartEntries getPartEntries(int index)
-
getPartEntries
public AqdefObjectModel.PartEntries getPartEntries(PartIndex index)
-
getParts
public List<AqdefObjectModel.PartEntries> getParts()
- Returns:
- all parts in this object model
-
getCharacteristicIndexes
public List<CharacteristicIndex> getCharacteristicIndexes(PartIndex partIndex)
Returns indexes of all characteristics of a part with the given index.- Returns:
-
getCharacteristicEntries
public AqdefObjectModel.CharacteristicEntries getCharacteristicEntries(int partIndex, int characteristicIndex)
-
getCharacteristicEntries
public AqdefObjectModel.CharacteristicEntries getCharacteristicEntries(CharacteristicIndex characteristicIndex)
-
getCharacteristics
public List<AqdefObjectModel.CharacteristicEntries> getCharacteristics(PartIndex partIndex)
Returns all the characteristics of a part with the given index.- Parameters:
partIndex-- Returns:
-
getRootCharacteristics
public List<AqdefObjectModel.CharacteristicEntries> getRootCharacteristics(PartIndex partIndex)
Returns all the characteristics of a part with the given index that are root of characteristic hierarchy (has no parent characteristics).- Parameters:
partIndex-- Returns:
-
getChildCharacteristics
public List<AqdefObjectModel.CharacteristicEntries> getChildCharacteristics(CharacteristicIndex characteristicIndex)
Returns all child characteristics of the characteristic with the given index.- Parameters:
characteristicIndex-- Returns:
-
getChildGroups
public List<AqdefObjectModel.GroupEntries> getChildGroups(CharacteristicIndex characteristicIndex)
Returns all child groups of the characteristic with the given index.- Parameters:
characteristicIndex-- Returns:
-
getGroupEntries
public AqdefObjectModel.GroupEntries getGroupEntries(GroupIndex groupIndex)
-
getGroups
public List<AqdefObjectModel.GroupEntries> getGroups(PartIndex partIndex)
Returns all the groups of a part with the given index.- Parameters:
partIndex-- Returns:
-
getRootGroups
public List<AqdefObjectModel.GroupEntries> getRootGroups(PartIndex partIndex)
Returns all the groups of a part with the given index that are root of group hierarchy (has no parent group).- Parameters:
partIndex-- Returns:
-
getChildCharacteristics
public List<AqdefObjectModel.CharacteristicEntries> getChildCharacteristics(GroupIndex groupIndex)
Returns all child characteristics of the characteristic with the given index.- Parameters:
groupIndex-- Returns:
-
getChildGroups
public List<AqdefObjectModel.GroupEntries> getChildGroups(GroupIndex groupIndex)
Returns all child groups of the characteristic with the given index.- Parameters:
groupIndex-- Returns:
-
getValueIndexes
public List<ValueIndex> getValueIndexes(CharacteristicIndex characteristicIndex)
Returns indexes of all values of a characteristics with the given index.- Returns:
-
getValueIndexes
public List<ValueIndex> getValueIndexes()
Returns indexes of all values in this object model.- Returns:
-
getValueEntries
public AqdefObjectModel.ValueEntries getValueEntries(int partIndex, int characteristicIndex, int valueIndex)
-
getValueEntries
public AqdefObjectModel.ValueEntries getValueEntries(ValueIndex valueIndex)
-
getValues
public List<AqdefObjectModel.ValueEntries> getValues()
- Returns:
- all the values in this model object
-
getValueEntries
@Deprecated public List<AqdefObjectModel.ValueEntries> getValueEntries(CharacteristicIndex characteristicIndex)
Deprecated.usegetValues(CharacteristicIndex)instead- Parameters:
characteristicIndex-- Returns:
-
getValues
public List<AqdefObjectModel.ValueEntries> getValues(CharacteristicIndex characteristicIndex)
-
getValueSets
public List<AqdefObjectModel.ValueSet> getValueSets(PartIndex partIndex)
-
findPartIndexForCharacteristic
public PartIndex findPartIndexForCharacteristic(int characteristicIndex)
Finds part index to which the given characteristic index belongs.You should call this method only after this
AqdefObjectModelis fully created.- Parameters:
characteristicIndex-- Returns:
-
findCharacteristicIndexesForPart
public Set<CharacteristicIndex> findCharacteristicIndexesForPart(PartIndex partIndex, AqdefObjectModel.CharacteristicOfSinglePartPredicate predicate)
-
forEachPart
public void forEachPart(AqdefObjectModel.PartConsumer consumer)
Iterates through all parts- Parameters:
consumer-
-
forEachCharacteristic
public void forEachCharacteristic(AqdefObjectModel.CharacteristicConsumer consumer)
Iterates through all characteristics of all parts- Parameters:
consumer-
-
forEachCharacteristic
public void forEachCharacteristic(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicOfSinglePartConsumer consumer)
Iterates through all characteristics of the given part. Most of the time it will be used together withforEachPart(PartConsumer).model.forEachPart(part -> { // do something with the part model.forEachCharacteristic(part, characteristic -> { // do something with the characteristic }); })- Parameters:
part-consumer-
-
forEachGroup
public void forEachGroup(AqdefObjectModel.GroupConsumer consumer)
Iterates through all logical groups of all parts- Parameters:
consumer-
-
forEachGroup
public void forEachGroup(AqdefObjectModel.PartEntries part, AqdefObjectModel.GroupOfSinglePartConsumer consumer)
Iterates through all logical groups of the given part. Similar toforEachCharacteristic(PartEntries, CharacteristicOfSinglePartConsumer)- Parameters:
part-consumer-
-
forEachValue
public void forEachValue(AqdefObjectModel.ValueConsumer consumer)
Iterates through all values.- Parameters:
consumer-
-
forEachValue
public void forEachValue(AqdefObjectModel.PartEntries part, AqdefObjectModel.ValueOfSinglePartConsumer consumer)
Iterates through all values of the given part. Most of the time it will be used together withforEachPart(PartConsumer).model.forEachPart(part -> { // do something with the part model.forEachValue(part, (characteristic, value) -> { // do something with the value }); })- Parameters:
part-consumer-
-
forEachValue
public void forEachValue(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicEntries characteristic, AqdefObjectModel.ValueOfSingleCharacteristicConsumer consumer)
Iterates through all values of the given characteristic. Most of the time it will be used together withforEachCharacteristic(CharacteristicConsumer).model.forEachCharacteristic(part, characteristic -> { // do something with the characteristic model.forEachValue(part, characteristic, value -> { // do something with the value }); })- Parameters:
part-characteristic-consumer-
-
filterParts
public void filterParts(AqdefObjectModel.PartPredicate predicate)
Removes all parts that do not match the given predicate. If a part is removed it's characteristics and values are also removed.- Parameters:
predicate-
-
filterCharacteristics
public void filterCharacteristics(AqdefObjectModel.CharacteristicPredicate predicate)
Removes all characteristics that do not match the given predicate. If a characteristic is removed it's values are also removed.- Parameters:
predicate-
-
filterCharacteristics
public void filterCharacteristics(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicOfSinglePartPredicate predicate)
Removes all characteristics of the given part that do not match the given predicate. If a characteristic is removed it's values are also removed.- Parameters:
part-predicate-
-
filterGroups
public void filterGroups(AqdefObjectModel.GroupPredicate predicate)
Removes all groups that do not match the given predicate.- Parameters:
predicate-
-
filterGroups
public void filterGroups(AqdefObjectModel.PartEntries part, AqdefObjectModel.GroupOfSinglePartPredicate predicate)
Removes all groups of the given part that do not match the given predicate.- Parameters:
part-predicate-
-
filterValues
public void filterValues(AqdefObjectModel.ValuePredicate predicate)
Removes all values that do not match the given predicate.- Parameters:
predicate-
-
filterValues
public void filterValues(AqdefObjectModel.PartEntries part, AqdefObjectModel.ValueOfSinglePartPredicate predicate)
Removes all values of the given part that do not match the given predicate.- Parameters:
part-predicate-
-
filterValues
public void filterValues(AqdefObjectModel.PartEntries part, AqdefObjectModel.CharacteristicEntries characteristic, AqdefObjectModel.ValueOfSingleCharacteristicPredicate predicate)
Removes all values of the given characteristic that do not match the given predicate.- Parameters:
part-characteristic-predicate-
-
containsPart
public boolean containsPart(AqdefObjectModel.PartEntries part)
-
containsCharacteristic
public boolean containsCharacteristic(AqdefObjectModel.CharacteristicEntries characteristic)
-
containsValue
public boolean containsValue(AqdefObjectModel.ValueEntries value)
-
getAnyValueOf
public Object getAnyValueOf(KKey key)
Finds value of the given K-key from any part / characteristic / value.There is no guarantee from which part / characteristic / value this K-key value will be taken (whether from the first or other).
- Parameters:
key- any K-key of part / characteristic / value- Returns:
- Throws:
IllegalArgumentException- if the K-key is not for part / characteristic / value lavel.
-
normalize
public void normalize()
Normalize the AQDEF content.- Apply all /0 K-keys on all parts / characteristics / values and then remove them from object model.
- Complement the hierarchy so there are no nodes/characteristics wihout a parent part node. This may happen when hierarchy was created from simple characteristics grouping (K2030/K2031).
-
getCharacteristicCount
public int getCharacteristicCount()
Returns total number of characteristics of all parts in this object model- Returns:
-
getValueCount
public int getValueCount()
Returns total number of values of all parts and characteristics in this object model- Returns:
-
-