Constructor: |
public SOAPArrayType(String s,
PrefixResolver m) {
int firstbrace = s.indexOf('[');
if (firstbrace < 0)
throw new XmlValueOutOfRangeException();
// grab the QName
String firstpart = XmlWhitespace.collapse(s.substring(0, firstbrace), XmlWhitespace.WS_COLLAPSE);
int firstcolon = firstpart.indexOf(':');
String prefix = "";
if (firstcolon >= 0)
prefix = firstpart.substring(0, firstcolon);
String uri = m.getNamespaceForPrefix(prefix);
if (uri == null)
throw new XmlValueOutOfRangeException();
_type = QNameHelper.forLNS(firstpart.substring(firstcolon + 1), uri);
initDimensions(s, firstbrace);
}
Parses a SOAP 1.1 array type string.
Since an array type string contains a QName, a prefix resolver
must be passed. |
public SOAPArrayType(QName name,
String dimensions) {
int firstbrace = dimensions.indexOf('[');
if (firstbrace < 0)
{
_type = name;
_ranks = EMPTY_INT_ARRAY;
dimensions = XmlWhitespace.collapse(dimensions, XmlWhitespace.WS_COLLAPSE);
String[] dimStrings = dimensions.split(" ");
for (int i = 0; i < dimStrings.length; i++)
{
String dimString = dimStrings[i];
if (dimString.equals("*"))
{
_dimensions[i] = -1;
// _hasIndeterminateDimensions = true;
}
else
{
try
{
_dimensions[i] = Integer.parseInt(dimStrings[i]);
}
catch (Exception e)
{
throw new XmlValueOutOfRangeException();
}
}
}
}
else
{
_type = name;
initDimensions(dimensions, firstbrace);
}
}
Parses SOAP 1.1(advanced) array type strings.
Since in SOAP 1.1(advanced) the dimension specification is separated from the
QName for the underlying type, these are passed in separate
arguments. |
public SOAPArrayType(SOAPArrayType nested,
int[] dimensions) {
_type = nested._type;
_ranks = new int[nested._ranks.length + 1];
System.arraycopy(nested._ranks, 0, _ranks, 0, nested._ranks.length);
_ranks[_ranks.length - 1] = nested._dimensions.length;
_dimensions = new int[dimensions.length];
System.arraycopy(dimensions, 0, _dimensions, 0, dimensions.length);
}
Given a nested SOAPArrayType and a set of dimensions for the outermost
array, comes up with the right SOAPArrayType for the whole thing.
E.g.,
Nested foo:bar[,][][,,][1,2]
Dimensions [6,7,8]
Result -> foo:bar[,][][,,][,][6,7,8] |
Method from org.apache.xmlbeans.soap.SOAPArrayType Detail: |
public boolean containsNestedArrays() {
return (_ranks.length > 0);
}
True if this array contains nested arrays. Equivalent
to (getRanks().length > 0). |
public boolean equals(Object obj) {
if (obj == this)
return true;
if (!obj.getClass().equals(getClass()))
return false;
SOAPArrayType sat = (SOAPArrayType)obj;
if (!_type.equals(sat._type))
return false;
if (_ranks.length != sat._ranks.length)
return false;
if (_dimensions.length != sat._dimensions.length)
return false;
for (int i = 0; i < _ranks.length; i++)
if (_ranks[i] != sat._ranks[i])
return false;
for (int i = 0; i < _dimensions.length; i++)
if (_dimensions[i] != sat._dimensions[i])
return false;
return true;
}
|
public int[] getDimensions() {
int[] result = new int[_dimensions.length];
System.arraycopy(_dimensions, 0, result, 0, result.length);
return result;
}
Returns the array of dimensions. |
public QName getQName() {
return _type;
}
Returns the QName for the referenced type. |
public int[] getRanks() {
int[] result = new int[_ranks.length];
System.arraycopy(_ranks, 0, result, 0, result.length);
return result;
}
Returns the array of ranks for inner nested arrays.
In SOAP 1.1-advanced, this is always an array of length zero.
In SOAP 1.1, this array reflects the ranks of nested
arrays. For example foo:bar[,][,,][][5,6] will produce
a ranks result of 2, 3, 1. |
public int hashCode() {
return (_type.hashCode() + _dimensions.length + _ranks.length + (_dimensions.length == 0 ? 0 : _dimensions[0]));
}
|
public boolean isSameRankAs(SOAPArrayType otherType) {
if (_ranks.length != otherType._ranks.length)
return false;
for (int i = 0; i < _ranks.length; i++)
{
if (_ranks[i] != otherType._ranks[i])
return false;
}
if (_dimensions.length != otherType._dimensions.length)
return false;
return true;
}
True if the ranks for the passed SOAPArrayType
are equal to this one.
Does NOT compare the _type fields. |
public SOAPArrayType nestedArrayType() {
if (!containsNestedArrays())
throw new IllegalStateException();
SOAPArrayType result = new SOAPArrayType();
result._type = _type;
result._ranks = new int[_ranks.length - 1];
System.arraycopy(_ranks, 0, result._ranks, 0, result._ranks.length);
result._dimensions = new int[_ranks[_ranks.length - 1]];
for (int i = 0; i < result._dimensions.length; i++)
result._dimensions[i] = -1;
// result._hasIndeterminateDimensions = (result._dimensions.length > 0);
return result;
}
Constructs a SOAPArrayType reflecting the dimensions
of the next nested array. |
public static SOAPArrayType newSoap12Array(QName itemType,
String arraySize) {
int [] ranks = EMPTY_INT_ARRAY;
arraySize = XmlWhitespace.collapse(arraySize, XmlWhitespace.WS_COLLAPSE);
String[] dimStrings = arraySize.split(" ");
int[] dimensions = new int[dimStrings.length];
for (int i = 0; i < dimStrings.length; i++)
{
String dimString = dimStrings[i];
if (i==0 && dimString.equals("*"))
{
dimensions[i] = -1;
// _hasIndeterminateDimensions = true;
}
else
{
try
{
dimensions[i] = Integer.parseInt(dimStrings[i]);
}
catch (Exception e)
{
throw new XmlValueOutOfRangeException();
}
}
}
SOAPArrayType sot = new SOAPArrayType();
sot._ranks = ranks;
sot._type = itemType;
sot._dimensions = dimensions;
return sot;
}
SOAP 1.2
Constructs a SOAPArrayType from soap-enc:itemType and
soap-enc:arraySize attributes |
public static int[] parseSoap11Index(String inbraces) {
inbraces = XmlWhitespace.collapse(inbraces, XmlWhitespace.WS_COLLAPSE);
if (!inbraces.startsWith("[") || !inbraces.endsWith("]"))
throw new IllegalArgumentException("Misformed SOAP 1.1 index: must be contained in braces []");
return internalParseCommaIntString(inbraces.substring(1, inbraces.length() - 1));
}
Given SOAP 1.1-formatted index string, returns an array
index. For example, given "[4,3,5]", returns an int array
containing 4, 3, and 5. |
public String soap11DimensionString() {
return soap11DimensionString(_dimensions);
}
Returns the dimensions as a string, e.g., [,][2,3,4] |
public String soap11DimensionString(int[] actualDimensions) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < _ranks.length; i++)
{
sb.append('[');
for (int j = 1; j < _ranks[i]; j++)
sb.append(',');
sb.append(']');
}
sb.append('[');
for (int i = 0; i < actualDimensions.length; i++)
{
if (i > 0)
sb.append(',');
if (actualDimensions[i] >= 0)
sb.append(actualDimensions[i]);
}
sb.append(']');
return sb.toString();
}
Given an actual set of dimensions that may differ from
the default that is stored, outputs the soap arrayType
string. |
public String soap12DimensionString(int[] actualDimensions) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < actualDimensions.length; i++)
{
if (i > 0)
sb.append(' ');
if (actualDimensions[i] >= 0)
sb.append(actualDimensions[i]);
}
return sb.toString();
}
SOAP 1.2
Given an actual set of dimensions that may differ from
the default that is stored, outputs the soap arraySize
string. |