當前位置: 首頁>>代碼示例>>Java>>正文


Java IonReader類代碼示例

本文整理匯總了Java中software.amazon.ion.IonReader的典型用法代碼示例。如果您正苦於以下問題:Java IonReader類的具體用法?Java IonReader怎麽用?Java IonReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IonReader類屬於software.amazon.ion包,在下文中一共展示了IonReader類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseErrorCode

import software.amazon.ion.IonReader; //導入依賴的package包/類
@Override
public String parseErrorCode(HttpResponse response, JsonContent jsonContents) {
    IonReader reader = ionSystem.newReader(jsonContents.getRawContent());
    try {
        IonType type = reader.next();
        if (type != IonType.STRUCT) {
            throw new SdkClientException(String.format("Can only get error codes from structs (saw %s), request id %s",
                                                       type, getRequestId(response)));
        }

        boolean errorCodeSeen = false;
        String errorCode = null;
        String[] annotations = reader.getTypeAnnotations();
        for (String annotation : annotations) {
            if (annotation.startsWith(TYPE_PREFIX)) {
                if (errorCodeSeen) {
                    throw new SdkClientException(String.format("Multiple error code annotations found for request id %s",
                                                               getRequestId(response)));
                } else {
                    errorCodeSeen = true;
                    errorCode = annotation.substring(TYPE_PREFIX.length());
                }
            }
        }

        return errorCode;
    } finally {
        IoUtils.closeQuietly(reader, log);
    }
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:31,代碼來源:IonErrorCodeParser.java

示例2: parseErrorCode

import software.amazon.ion.IonReader; //導入依賴的package包/類
@Override
public String parseErrorCode(HttpResponse response, JsonContent jsonContents) {
    IonReader reader = ionSystem.newReader(jsonContents.getRawContent());
    try {
        IonType type = reader.next();
        if (type != IonType.STRUCT) {
            throw new SdkClientException(String.format("Can only get error codes from structs (saw %s), request id %s", type, getRequestId(response)));
        }

        boolean errorCodeSeen = false;
        String errorCode = null;
        String[] annotations = reader.getTypeAnnotations();
        for (String annotation : annotations) {
            if (annotation.startsWith(TYPE_PREFIX)) {
                if (errorCodeSeen) {
                    throw new SdkClientException(String.format("Multiple error code annotations found for request id %s", getRequestId(response)));
                } else {
                    errorCodeSeen = true;
                    errorCode = annotation.substring(TYPE_PREFIX.length());
                }
            }
        }

        return errorCode;
    } finally {
        IOUtils.closeQuietly(reader, log);
    }
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:29,代碼來源:IonErrorCodeParser.java

示例3: doAssert

import software.amazon.ion.IonReader; //導入依賴的package包/類
@Override
protected void doAssert(LoggedRequest request) throws Exception {
    IonReader expected = ION_SYSTEM.newReader(ionEquals);
    IonReader actual = ION_SYSTEM.newReader(request.getBody());
    assertIonReaderEquals(expected, actual);
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:7,代碼來源:IonBodyAssertion.java

示例4: IonParser

import software.amazon.ion.IonReader; //導入依賴的package包/類
IonParser(IonReader reader, boolean shouldCloseReader) {
    super(Feature.collectDefaults());
    this.reader = reader;
    this.shouldCloseReader = shouldCloseReader;
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:6,代碼來源:IonParser.java

示例5: write

import software.amazon.ion.IonReader; //導入依賴的package包/類
public static void write(String data, IonWriter writer) throws IOException {
    IonReader reader = SYSTEM.newReader(data);
    writer.writeValues(reader);
    writer.close();
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:6,代碼來源:IonParserTest.java

示例6: IonParser

import software.amazon.ion.IonReader; //導入依賴的package包/類
public IonParser(IonReader reader, boolean shouldCloseReader) {
    super(Feature.collectDefaults());
    this.reader = reader;
    this.shouldCloseReader = shouldCloseReader;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:6,代碼來源:IonParser.java


注:本文中的software.amazon.ion.IonReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。