if (StringUtil.splitConcatenateExcessTokens(fields[i], keyAndValue, TAG_KEY_VALUE_SEPARATOR_CHAR) != 2) { reportErrorParsingLine("Problem parsing " + HEADER_LINE_START + mHeaderRecordType + " key:value pair", SAMValidationError.Type.POORLY_FORMATTED_HEADER_TAG, null);
if (StringUtil.splitConcatenateExcessTokens(fields[i], keyAndValue, TAG_KEY_VALUE_SEPARATOR_CHAR) != 2) { reportErrorParsingLine("Problem parsing " + HEADER_LINE_START + mHeaderRecordType + " key:value pair", SAMValidationError.Type.POORLY_FORMATTED_HEADER_TAG, null);
if (StringUtil.splitConcatenateExcessTokens(fields[i], keyAndValue, TAG_KEY_VALUE_SEPARATOR_CHAR) != 2) { reportErrorParsingLine("Problem parsing " + HEADER_LINE_START + mHeaderRecordType + " key:value pair", SAMValidationError.Type.POORLY_FORMATTED_HEADER_TAG, null);
/** * Convert typed tag in SAM text format (name:type:value) into tag name and Object value representation. * @param tag SAM text format name:type:value tag. * @return Tag name as 2-character String, and tag value in appropriate class based on tag type. * If value is an unsigned array, then the value is a TagValueAndUnsignedArrayFlag object. */ public Map.Entry<String, Object> decode(final String tag) { final int numFields = StringUtil.splitConcatenateExcessTokens(tag, fields, ':'); if (numFields != TextTagCodec.NUM_TAG_FIELDS && numFields != TextTagCodec.NUM_TAG_FIELDS - 1) { throw new SAMFormatException("Not enough fields in tag '" + tag + "'"); } final String key = fields[0]; final String type = fields[1]; final String stringVal = numFields == TextTagCodec.NUM_TAG_FIELDS ? fields[2] : ""; final Object val = convertStringToObject(type, stringVal); return new Map.Entry<String, Object>() { @Override public String getKey() { return key; } @Override public Object getValue() { return val; } @Override public Object setValue(final Object o) { throw new UnsupportedOperationException(); } }; }
/** * Convert typed tag in SAM text format (name:type:value) into tag name and Object value representation. * @param tag SAM text format name:type:value tag. * @return Tag name as 2-character String, and tag value in appropriate class based on tag type. * If value is an unsigned array, then the value is a TagValueAndUnsignedArrayFlag object. */ public Map.Entry<String, Object> decode(final String tag) { final int numFields = StringUtil.splitConcatenateExcessTokens(tag, fields, ':'); if (numFields != TextTagCodec.NUM_TAG_FIELDS && numFields != TextTagCodec.NUM_TAG_FIELDS - 1) { throw new SAMFormatException("Not enough fields in tag '" + tag + "'"); } final String key = fields[0]; final String type = fields[1]; final String stringVal = numFields == TextTagCodec.NUM_TAG_FIELDS ? fields[2] : ""; final Object val = convertStringToObject(type, stringVal); return new Map.Entry<String, Object>() { @Override public String getKey() { return key; } @Override public Object getValue() { return val; } @Override public Object setValue(final Object o) { throw new UnsupportedOperationException(); } }; }
/** * Convert typed tag in SAM text format (name:type:value) into tag name and Object value representation. * @param tag SAM text format name:type:value tag. * @return Tag name as 2-character String, and tag value in appropriate class based on tag type. * If value is an unsigned array, then the value is a TagValueAndUnsignedArrayFlag object. */ public Map.Entry<String, Object> decode(final String tag) { final int numFields = StringUtil.splitConcatenateExcessTokens(tag, fields, ':'); if (numFields != TextTagCodec.NUM_TAG_FIELDS) { throw new SAMFormatException("Not enough fields in tag '" + tag + "'"); } final String key = fields[0]; final String type = fields[1]; final String stringVal = fields[2]; final Object val = convertStringToObject(type, stringVal); return new Map.Entry<String, Object>() { public String getKey() { return key; } public Object getValue() { return val; } public Object setValue(final Object o) { throw new UnsupportedOperationException(); } }; }
private static Object covertStringArrayToObject(final String stringVal) { final String[] elementTypeAndValue = new String[2]; final int numberOfTokens = StringUtil.splitConcatenateExcessTokens(stringVal, elementTypeAndValue, ',');
private static Object covertStringArrayToObject(final String stringVal) { final String[] elementTypeAndValue = new String[2]; final int numberOfTokens = StringUtil.splitConcatenateExcessTokens(stringVal, elementTypeAndValue, ',');
private Object covertStringArrayToObject(final String stringVal) { final String[] elementTypeAndValue = new String[2]; if (StringUtil.splitConcatenateExcessTokens(stringVal, elementTypeAndValue, ',') != 2) { throw new SAMFormatException("Tag of type B should have an element type followed by comma");