Java Code Examples for com.google.ipc.invalidation.external.client.types.ObjectId#newInstance()
The following examples show how to use
com.google.ipc.invalidation.external.client.types.ObjectId#newInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvalidationPreferences.java From 365browser with Apache License 2.0 | 6 votes |
/** * Converts the given object id string stored in preferences to an object id. * Returns null if the string does not represent a valid object id. */ private ObjectId getObjectId(String objectIdString) { int separatorPos = objectIdString.indexOf(':'); // Ensure that the separator is surrounded by at least one character on each side. if (separatorPos < 1 || separatorPos == objectIdString.length() - 1) { return null; } int objectSource; try { objectSource = Integer.parseInt(objectIdString.substring(0, separatorPos)); } catch (NumberFormatException e) { return null; } byte[] objectName = objectIdString.substring(separatorPos + 1).getBytes(); return ObjectId.newInstance(objectSource, objectName); }
Example 2
Source File: InvalidationPreferences.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * Converts the given object id string stored in preferences to an object id. * Returns null if the string does not represent a valid object id. */ private ObjectId getObjectId(String objectIdString) { int separatorPos = objectIdString.indexOf(':'); // Ensure that the separator is surrounded by at least one character on each side. if (separatorPos < 1 || separatorPos == objectIdString.length() - 1) { return null; } int objectSource; try { objectSource = Integer.parseInt(objectIdString.substring(0, separatorPos)); } catch (NumberFormatException e) { return null; } byte[] objectName = objectIdString.substring(separatorPos + 1).getBytes(); return ObjectId.newInstance(objectSource, objectName); }
Example 3
Source File: InvalidationPreferences.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * Converts the given object id string stored in preferences to an object id. * Returns null if the string does not represent a valid object id. */ private ObjectId getObjectId(String objectIdString) { int separatorPos = objectIdString.indexOf(':'); // Ensure that the separator is surrounded by at least one character on each side. if (separatorPos < 1 || separatorPos == objectIdString.length() - 1) { return null; } int objectSource; try { objectSource = Integer.parseInt(objectIdString.substring(0, separatorPos)); } catch (NumberFormatException e) { return null; } byte[] objectName = objectIdString.substring(separatorPos + 1).getBytes(); return ObjectId.newInstance(objectSource, objectName); }
Example 4
Source File: ProtoWrapperConverter.java From 365browser with Apache License 2.0 | 4 votes |
/** * Converts an object id protocol buffer {@code objectId} to the * corresponding external type and returns it. */ public static ObjectId convertFromObjectIdProto(ObjectIdP objectIdProto) { Preconditions.checkNotNull(objectIdProto); return ObjectId.newInstance(objectIdProto.getSource(), objectIdProto.getName().getByteArray()); }
Example 5
Source File: ExampleListener.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Gets object ID given index. */ private static ObjectId getObjectId(int i) { return ObjectId.newInstance(DEMO_SOURCE, (OBJECT_ID_PREFIX + i).getBytes()); }
Example 6
Source File: ProtoConverter.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Converts an object id protocol buffer {@code objectId} to the * corresponding external type and returns it. */ public static ObjectId convertFromObjectIdProto(ObjectIdP objectIdProto) { Preconditions.checkNotNull(objectIdProto); return ObjectId.newInstance(objectIdProto.getSource(), objectIdProto.getName().toByteArray()); }
Example 7
Source File: ParcelableObjectId.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Creates a new wrapper and object id by reading data from a parcel. */ private ParcelableObjectId(Parcel in) { int source = in.readInt(); byte[] value = in.createByteArray(); objectId = ObjectId.newInstance(source, value); }
Example 8
Source File: ExampleListener.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Gets object ID given index. */ private static ObjectId getObjectId(int i) { return ObjectId.newInstance(DEMO_SOURCE, (OBJECT_ID_PREFIX + i).getBytes()); }
Example 9
Source File: ProtoConverter.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Converts an object id protocol buffer {@code objectId} to the * corresponding external type and returns it. */ public static ObjectId convertFromObjectIdProto(ObjectIdP objectIdProto) { Preconditions.checkNotNull(objectIdProto); return ObjectId.newInstance(objectIdProto.getSource(), objectIdProto.getName().toByteArray()); }
Example 10
Source File: ParcelableObjectId.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Creates a new wrapper and object id by reading data from a parcel. */ private ParcelableObjectId(Parcel in) { int source = in.readInt(); byte[] value = in.createByteArray(); objectId = ObjectId.newInstance(source, value); }
Example 11
Source File: ModelTypeHelper.java From 365browser with Apache License 2.0 | 2 votes |
/** * Converts a notification type into an ObjectId. * * If the model type is not an invalidation type, this function uses the string "NULL". */ private static ObjectId toObjectId(String notificationType) { String objectIdString = isInvalidationType(notificationType) ? notificationType : "NULL"; return ObjectId.newInstance(Types.ObjectSource.CHROME_SYNC, objectIdString.getBytes()); }