当前位置: 首页>>代码示例>>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;未经允许,请勿转载。