Package kala.compress.harmony.unpack200
Class NewAttributeBands
- java.lang.Object
-
- kala.compress.harmony.unpack200.BandSet
-
- kala.compress.harmony.unpack200.NewAttributeBands
-
public class NewAttributeBands extends BandSet
Sets of bands relating to a non-predefined attribute
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceNewAttributeBands.AttributeLayoutElementAn AttributeLayoutElement is a part of an attribute layout and has one or more bands associated with it, which transmit the AttributeElement data for successive Attributes of this type.classNewAttributeBands.Callstatic classNewAttributeBands.CallableclassNewAttributeBands.Integralprivate static classNewAttributeBands.LayoutElementclassNewAttributeBands.ReferenceConstant Pool ReferenceclassNewAttributeBands.ReplicationA replication is an array of layout elements, with an associated countclassNewAttributeBands.UnionA Union is a type of layout element where the tag value acts as a selector for one of the union casesclassNewAttributeBands.UnionCaseA Union case
-
Field Summary
Fields Modifier and Type Field Description private AttributeLayoutattributeLayoutprotected java.util.List<NewAttributeBands.AttributeLayoutElement>attributeLayoutElementsprivate intbackwardsCallCount
-
Constructor Summary
Constructors Constructor Description NewAttributeBands(Segment segment, AttributeLayout attributeLayout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBackwardsCallCount()BHSDCodecgetCodec(java.lang.String layoutElement)Returns theBHSDCodecthat should be used for the given layout element.private AttributegetOneAttribute(int index, java.util.List<NewAttributeBands.AttributeLayoutElement> elements)Gets one attribute at the given index from the various bands.private java.io.StringReadergetStreamUpToMatchingBracket(java.io.StringReader stream)Utility method to get the contents of the given stream, up to the next], (ignoring pairs of brackets[and])java.util.List<Attribute>parseAttributes(java.io.InputStream in, int occurrenceCount)Parse the bands relating to this AttributeLayout and return the correct class file attributes as a List ofAttribute.private voidparseLayout()Tokenize the layout into AttributeElementsvoidread(java.io.InputStream in)private java.util.List<NewAttributeBands.LayoutElement>readBody(java.io.StringReader stream)Read a 'body' section of the layout from the given streamprivate NewAttributeBands.AttributeLayoutElementreadNextAttributeElement(java.io.StringReader stream)private NewAttributeBands.LayoutElementreadNextLayoutElement(java.io.StringReader stream)private NewAttributeBands.UnionCasereadNextUnionCase(java.io.StringReader stream)Read a UnionCase from the stream.private java.lang.IntegerreadNumber(java.io.StringReader stream)Read a number from the stream and return itprivate java.lang.StringreadUpToMatchingBracket(java.io.StringReader stream)Gets the contents of the given stream, up to the next], (ignoring pairs of brackets[and])private voidresolveCalls()Resolve calls in the attribute layout and returns the number of backwards callsprivate intresolveCallsForElement(int i, NewAttributeBands.Callable currentCallable, NewAttributeBands.LayoutElement layoutElement)voidsetBackwardsCalls(int[] backwardsCalls)Once the attribute bands have been read the callables can be informed about the number of times each is subject to a backwards call.voidunpack()-
Methods inherited from class kala.compress.harmony.unpack200.BandSet
decodeBandInt, decodeBandInt, getReferences, getReferences, parseCPClassReferences, parseCPDescriptorReferences, parseCPDoubleReferences, parseCPFieldRefReferences, parseCPFloatReferences, parseCPInterfaceMethodRefReferences, parseCPIntReferences, parseCPLongReferences, parseCPMethodRefReferences, parseCPSignatureReferences, parseCPSignatureReferences, parseCPStringReferences, parseCPUTF8References, parseCPUTF8References, parseFlags, parseFlags, parseFlags, parseFlags, parseReferences, parseReferences, unpack
-
-
-
-
Field Detail
-
attributeLayout
private final AttributeLayout attributeLayout
-
backwardsCallCount
private int backwardsCallCount
-
attributeLayoutElements
protected java.util.List<NewAttributeBands.AttributeLayoutElement> attributeLayoutElements
-
-
Constructor Detail
-
NewAttributeBands
public NewAttributeBands(Segment segment, AttributeLayout attributeLayout) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getBackwardsCallCount
public int getBackwardsCallCount()
-
getCodec
public BHSDCodec getCodec(java.lang.String layoutElement)
Returns theBHSDCodecthat should be used for the given layout element.- Parameters:
layoutElement- TODO- Returns:
- the
BHSDCodecthat should be used for the given layout element.
-
getOneAttribute
private Attribute getOneAttribute(int index, java.util.List<NewAttributeBands.AttributeLayoutElement> elements)
Gets one attribute at the given index from the various bands. The correct bands must have already been read in.- Parameters:
index- TODOelements- TODO- Returns:
- attribute at the given index.
-
getStreamUpToMatchingBracket
private java.io.StringReader getStreamUpToMatchingBracket(java.io.StringReader stream) throws java.io.IOExceptionUtility method to get the contents of the given stream, up to the next], (ignoring pairs of brackets[and])- Parameters:
stream-- Returns:
- Throws:
java.io.IOException- If an I/O error occurs.
-
parseAttributes
public java.util.List<Attribute> parseAttributes(java.io.InputStream in, int occurrenceCount) throws java.io.IOException, Pack200Exception
Parse the bands relating to this AttributeLayout and return the correct class file attributes as a List ofAttribute.- Parameters:
in- parse source.occurrenceCount- TODO- Returns:
- Class file attributes as a List of
Attribute. - Throws:
java.io.IOException- If an I/O error occurs.Pack200Exception- TODO
-
parseLayout
private void parseLayout() throws java.io.IOExceptionTokenize the layout into AttributeElements- Throws:
java.io.IOException- If an I/O error occurs.
-
read
public void read(java.io.InputStream in) throws java.io.IOException, Pack200Exception- Specified by:
readin classBandSet- Throws:
java.io.IOExceptionPack200Exception
-
readBody
private java.util.List<NewAttributeBands.LayoutElement> readBody(java.io.StringReader stream) throws java.io.IOException
Read a 'body' section of the layout from the given stream- Parameters:
stream-- Returns:
- List of LayoutElements
- Throws:
java.io.IOException- If an I/O error occurs.
-
readNextAttributeElement
private NewAttributeBands.AttributeLayoutElement readNextAttributeElement(java.io.StringReader stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readNextLayoutElement
private NewAttributeBands.LayoutElement readNextLayoutElement(java.io.StringReader stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readNextUnionCase
private NewAttributeBands.UnionCase readNextUnionCase(java.io.StringReader stream) throws java.io.IOException
Read a UnionCase from the stream.- Parameters:
stream- source stream.- Returns:
- A UnionCase from the stream.
- Throws:
java.io.IOException- If an I/O error occurs.
-
readNumber
private java.lang.Integer readNumber(java.io.StringReader stream) throws java.io.IOExceptionRead a number from the stream and return it- Parameters:
stream-- Returns:
- Throws:
java.io.IOException- If an I/O error occurs.
-
readUpToMatchingBracket
private java.lang.String readUpToMatchingBracket(java.io.StringReader stream) throws java.io.IOExceptionGets the contents of the given stream, up to the next], (ignoring pairs of brackets[and])- Parameters:
stream- input stream.- Returns:
- the contents of the given stream.
- Throws:
java.io.IOException- If an I/O error occurs.
-
resolveCalls
private void resolveCalls()
Resolve calls in the attribute layout and returns the number of backwards calls
-
resolveCallsForElement
private int resolveCallsForElement(int i, NewAttributeBands.Callable currentCallable, NewAttributeBands.LayoutElement layoutElement)
-
setBackwardsCalls
public void setBackwardsCalls(int[] backwardsCalls) throws java.io.IOExceptionOnce the attribute bands have been read the callables can be informed about the number of times each is subject to a backwards call. This method is used to set this information.- Parameters:
backwardsCalls- one int for each backwards callable, which contains the number of times that callable is subject to a backwards call.- Throws:
java.io.IOException- If an I/O error occurs.
-
unpack
public void unpack() throws java.io.IOException, Pack200Exception- Specified by:
unpackin classBandSet- Throws:
java.io.IOExceptionPack200Exception
-
-