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


Java JsonParseException類代碼示例

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


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

示例1: getPreKeys

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public List<PreKeyEntity> getPreKeys(PushAddress destination) throws IOException {
  try {
    String deviceId = String.valueOf(destination.getDeviceId());

    if (deviceId.equals("1"))
      deviceId = "*";

    String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(), deviceId);

    if (!Util.isEmpty(destination.getRelay())) {
      path = path + "?relay=" + destination.getRelay();
    }

    String responseText = makeRequest(path, "GET", null);
    PreKeyList response = PreKeyList.fromJson(responseText);

    return response.getKeys();
  } catch (JsonParseException e) {
    throw new IOException(e);
  } catch (NotFoundException nfe) {
    throw new UnregisteredUserException(destination.getNumber(), nfe);
  }
}
 
開發者ID:Securecom,項目名稱:Securecom-Text,代碼行數:24,代碼來源:PushServiceSocket.java

示例2: getPreKey

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public PreKeyEntity getPreKey(PushAddress destination) throws IOException {
  try {
    String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(),
                                String.valueOf(destination.getDeviceId()));

    if (!Util.isEmpty(destination.getRelay())) {
      path = path + "?relay=" + destination.getRelay();
    }

    String     responseText = makeRequest(path, "GET", null);
    PreKeyList response     = PreKeyList.fromJson(responseText);

    if (response.getKeys() == null || response.getKeys().size() < 1)
      throw new IOException("Empty prekey list");

    return response.getKeys().get(0);
  } catch (JsonParseException e) {
    throw new IOException(e);
  } catch (NotFoundException nfe) {
    throw new UnregisteredUserException(destination.getNumber(), nfe);
  }
}
 
開發者ID:Securecom,項目名稱:Securecom-Text,代碼行數:23,代碼來源:PushServiceSocket.java

示例3: deserialize

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
@Override
public byte[] deserialize(JsonElement jsonElement, Type type,
                          JsonDeserializationContext jsonDeserializationContext)
    throws JsonParseException
{
  try {
    return Base64.decodeWithoutPadding(jsonElement.getAsJsonPrimitive().getAsString());
  } catch (IOException e) {
    throw new JsonParseException(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:12,代碼來源:SignedPreKeyEntity.java

示例4: deserialize

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
@Override
public ECPublicKey deserialize(JsonElement jsonElement, Type type,
                                JsonDeserializationContext jsonDeserializationContext)
    throws JsonParseException
{
  try {
    return Curve.decodePoint(Base64.decodeWithoutPadding(jsonElement.getAsJsonPrimitive().getAsString()), 0);
  } catch (InvalidKeyException | IOException e) {
    throw new JsonParseException(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:12,代碼來源:PreKeyEntity.java

示例5: deserialize

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
@Override
public IdentityKey deserialize(JsonElement jsonElement, Type type,
                               JsonDeserializationContext jsonDeserializationContext)
    throws JsonParseException
{
  try {
    return new IdentityKey(Base64.decodeWithoutPadding(jsonElement.getAsJsonPrimitive().getAsString()), 0);
  } catch (InvalidKeyException | IOException e) {
    throw new JsonParseException(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:12,代碼來源:PreKeyResponse.java

示例6: fromStream

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public static NumberFilterStorage fromStream(InputStream in) throws IOException {
  try {
    return new Gson().fromJson(new BufferedReader(new InputStreamReader(in)),
                               NumberFilterStorage.class);
  } catch (JsonParseException jpe) {
    Log.w("NumberFilter", jpe);
    throw new IOException("JSON Parse Exception");
  }
}
 
開發者ID:Securecom,項目名稱:Securecom-Text,代碼行數:10,代碼來源:NumberFilter.java

示例7: getPreKeys

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public List<PreKeyBundle> getPreKeys(PushAddress destination) throws IOException {
  try {
    String deviceId = String.valueOf(destination.getDeviceId());

    if (deviceId.equals("1"))
      deviceId = "*";

    String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(), deviceId);

    if (!Util.isEmpty(destination.getRelay())) {
      path = path + "?relay=" + destination.getRelay();
    }

    String             responseText = makeRequest(path, "GET", null);
    PreKeyResponse     response     = PreKeyResponse.fromJson(responseText);
    List<PreKeyBundle> bundles      = new LinkedList<>();

    for (PreKeyResponseItem device : response.getDevices()) {
      ECPublicKey preKey                = null;
      ECPublicKey signedPreKey          = null;
      byte[]      signedPreKeySignature = null;
      int         preKeyId              = -1;
      int         signedPreKeyId        = -1;

      if (device.getSignedPreKey() != null) {
        signedPreKey          = device.getSignedPreKey().getPublicKey();
        signedPreKeyId        = device.getSignedPreKey().getKeyId();
        signedPreKeySignature = device.getSignedPreKey().getSignature();
      }

      if (device.getPreKey() != null) {
        preKeyId = device.getPreKey().getKeyId();
        preKey   = device.getPreKey().getPublicKey();
      }

      bundles.add(new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId,
                                   preKey, signedPreKeyId, signedPreKey, signedPreKeySignature,
                                   response.getIdentityKey()));
    }

    return bundles;
  } catch (JsonParseException e) {
    throw new IOException(e);
  } catch (NotFoundException nfe) {
    throw new UnregisteredUserException(destination.getNumber(), nfe);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:48,代碼來源:PushServiceSocket.java

示例8: getPreKey

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public PreKeyBundle getPreKey(PushAddress destination) throws IOException {
  try {
    String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(),
                                String.valueOf(destination.getDeviceId()));

    if (!Util.isEmpty(destination.getRelay())) {
      path = path + "?relay=" + destination.getRelay();
    }

    String         responseText = makeRequest(path, "GET", null);
    PreKeyResponse response     = PreKeyResponse.fromJson(responseText);

    if (response.getDevices() == null || response.getDevices().size() < 1)
      throw new IOException("Empty prekey list");

    PreKeyResponseItem device                = response.getDevices().get(0);
    ECPublicKey        preKey                = null;
    ECPublicKey        signedPreKey          = null;
    byte[]             signedPreKeySignature = null;
    int                preKeyId              = -1;
    int                signedPreKeyId        = -1;

    if (device.getPreKey() != null) {
      preKeyId = device.getPreKey().getKeyId();
      preKey   = device.getPreKey().getPublicKey();
    }

    if (device.getSignedPreKey() != null) {
      signedPreKeyId        = device.getSignedPreKey().getKeyId();
      signedPreKey          = device.getSignedPreKey().getPublicKey();
      signedPreKeySignature = device.getSignedPreKey().getSignature();
    }

    return new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId, preKey,
                            signedPreKeyId, signedPreKey, signedPreKeySignature, response.getIdentityKey());
  } catch (JsonParseException e) {
    throw new IOException(e);
  } catch (NotFoundException nfe) {
    throw new UnregisteredUserException(destination.getNumber(), nfe);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:42,代碼來源:PushServiceSocket.java

示例9: getPreKeys

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public List<PreKeyBundle> getPreKeys(PushAddress destination) throws IOException {
    try {
        String deviceId = String.valueOf(destination.getDeviceId());

        if (deviceId.equals("1"))
            deviceId = "*";

        String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(), deviceId);

        if (!Util.isEmpty(destination.getRelay())) {
            path = path + "?relay=" + destination.getRelay();
        }

        String             responseText = makeRequest(path, "GET", null);
        PreKeyResponse     response     = PreKeyResponse.fromJson(responseText);
        List<PreKeyBundle> bundles      = new LinkedList<>();

        for (PreKeyResponseItem device : response.getDevices()) {
            ECPublicKey preKey                = null;
            ECPublicKey signedPreKey          = null;
            byte[]      signedPreKeySignature = null;
            int         preKeyId              = -1;
            int         signedPreKeyId        = -1;

            if (device.getSignedPreKey() != null) {
                signedPreKey          = device.getSignedPreKey().getPublicKey();
                signedPreKeyId        = device.getSignedPreKey().getKeyId();
                signedPreKeySignature = device.getSignedPreKey().getSignature();
            }

            if (device.getPreKey() != null) {
                preKeyId = device.getPreKey().getKeyId();
                preKey   = device.getPreKey().getPublicKey();
            }

            bundles.add(new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId,
                    preKey, signedPreKeyId, signedPreKey, signedPreKeySignature,
                    response.getIdentityKey()));
        }

        return bundles;
    } catch (JsonParseException e) {
        throw new IOException(e);
    } catch (NotFoundException nfe) {
        throw new UnregisteredUserException(destination.getNumber(), nfe);
    }
}
 
開發者ID:Securecom,項目名稱:Securecom-Messaging,代碼行數:48,代碼來源:PushServiceSocket.java

示例10: getPreKey

import com.google.thoughtcrimegson.JsonParseException; //導入依賴的package包/類
public PreKeyBundle getPreKey(PushAddress destination) throws IOException {
    try {
        String path = String.format(PREKEY_DEVICE_PATH, destination.getNumber(),
                String.valueOf(destination.getDeviceId()));

        if (!Util.isEmpty(destination.getRelay())) {
            path = path + "?relay=" + destination.getRelay();
        }

        String         responseText = makeRequest(path, "GET", null);
        PreKeyResponse response     = PreKeyResponse.fromJson(responseText);

        if (response.getDevices() == null || response.getDevices().size() < 1)
            throw new IOException("Empty prekey list");

        PreKeyResponseItem device                = response.getDevices().get(0);
        ECPublicKey        preKey                = null;
        ECPublicKey        signedPreKey          = null;
        byte[]             signedPreKeySignature = null;
        int                preKeyId              = -1;
        int                signedPreKeyId        = -1;

        if (device.getPreKey() != null) {
            preKeyId = device.getPreKey().getKeyId();
            preKey   = device.getPreKey().getPublicKey();
        }

        if (device.getSignedPreKey() != null) {
            signedPreKeyId        = device.getSignedPreKey().getKeyId();
            signedPreKey          = device.getSignedPreKey().getPublicKey();
            signedPreKeySignature = device.getSignedPreKey().getSignature();
        }

        return new PreKeyBundle(device.getRegistrationId(), device.getDeviceId(), preKeyId, preKey,
                signedPreKeyId, signedPreKey, signedPreKeySignature, response.getIdentityKey());
    } catch (JsonParseException e) {
        throw new IOException(e);
    } catch (NotFoundException nfe) {
        throw new UnregisteredUserException(destination.getNumber(), nfe);
    }
}
 
開發者ID:Securecom,項目名稱:Securecom-Messaging,代碼行數:42,代碼來源:PushServiceSocket.java


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