List of usage examples for com.google.gwt.user.client.rpc.impl ClientSerializationStreamReader prepareToRead
@Override
public void prepareToRead(String encoded) throws SerializationException
From source file:com.seanchenxi.gwt.storage.client.serializer.StorageRPCSerializerImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public <T> T deserialize(Class<? super T> clazz, String serializedString) throws SerializationException { if (serializedString == null) { return null; } else if (String.class.equals(clazz)) { return (T) serializedString; }/*from w w w. ja v a 2 s. co m*/ ClientSerializationStreamReader reader = new ClientSerializationStreamReader(TYPE_SERIALIZER); reader.prepareToRead(serializedString); Object obj = findType(clazz).read(reader); return obj != null ? (T) obj : null; }
From source file:de.csenk.gwt.ws.client.filter.serialization.ClientGWTSerializer.java
License:Open Source License
@Override public Object deserialize(String serializedContent) throws SerializationException { ClientSerializationStreamReader streamReader = new ClientSerializationStreamReader(serializer); streamReader.prepareToRead(serializedContent); String className = streamReader.readString(); if (className.equals("java.lang.String")) { return streamReader.readString(); } else {// w w w.jav a 2 s . co m return streamReader.readObject(); } }
From source file:fr.putnami.pwt.core.service.client.CommandSerializationStreamFactory.java
License:Open Source License
@Override public SerializationStreamReader createStreamReader(String encoded) throws SerializationException { ClientSerializationStreamReader clientSerializationStreamReader = new ClientSerializationStreamReader( this.serializer); String encodedResponse = encoded; if (encoded.startsWith("//OK") || encodedResponse.startsWith("//EX")) { encodedResponse = encodedResponse.substring(4); }//from w w w . ja v a 2 s .c om clientSerializationStreamReader.prepareToRead(encodedResponse); return clientSerializationStreamReader; }
From source file:net.zschech.gwt.comet.client.CometSerializer.java
License:Apache License
@SuppressWarnings("unchecked") public <T extends Serializable> T parse(String message) throws SerializationException { if (getMode() == SerialMode.RPC) { try {//from w ww .j a v a 2 s. com Serializer serializer = getSerializer(); ClientSerializationStreamReader reader = new ClientSerializationStreamReader(serializer); reader.prepareToRead(message); return (T) reader.readObject(); } catch (RuntimeException e) { throw new SerializationException(e); } } else { try { SerializationStreamReader reader = ClientWriterFactory.createReader(message); return (T) reader.readObject(); } catch (RuntimeException e) { throw new SerializationException(e); } } }
From source file:org.atmosphere.extensions.gwtwrapper.client.GwtClientSerializer.java
License:Apache License
public Object deserialize(String message) throws SerializationException { try {//from w w w .j av a 2 s .com Serializer serializer = getRPCSerializer(); ClientSerializationStreamReader reader = new ClientSerializationStreamReader(serializer); reader.prepareToRead(message); return reader.readObject(); } catch (RuntimeException e) { throw new SerializationException(e); } }
From source file:org.atmosphere.gwt.client.AtmosphereGWTSerializer.java
License:Apache License
@SuppressWarnings("unchecked") public <T extends Serializable> T parse(String message) throws SerializationException { if (getMode() == SerialMode.RPC) { try {//from w w w .ja v a2 s . c om Serializer serializer = getSerializer(); ClientSerializationStreamReader reader = new ClientSerializationStreamReader(serializer); reader.prepareToRead(message); return (T) reader.readObject(); } catch (RuntimeException e) { throw new SerializationException(e); } } else if (getMode() == SerialMode.DE_RPC) { try { SerializationStreamReader reader = ClientWriterFactory.createReader(message); return (T) reader.readObject(); } catch (RuntimeException e) { throw new SerializationException(e); } } else if (getMode() == SerialMode.PLAIN) { return (T) message; } else { throw new UnsupportedOperationException("Not implemented yet"); } }
From source file:org.atmosphere.gwt20.client.GwtRpcClientSerializer.java
License:Apache License
public Object deserialize(String raw) throws SerializationException { buffer.append(raw);//from w w w . j a va2 s. c o m // split up in different parts - based on the [] // this is necessary because multiple objects can be chunked in one single string int brackets = 0; int start = 0; List<String> messages = new ArrayList<String>(); int bufSize = buffer.length(); for (int i = 0; i < bufSize; i++) { // detect brackets if (buffer.charAt(i) == '[') { // account for arrays which use [ as the leading part of the type encoding final int nextIndex = i + 1; if (nextIndex < bufSize) { final char nextChar = buffer.charAt(nextIndex); if (nextChar != 'L' && nextChar != 'B' && nextChar != 'C' && nextChar != 'S' && nextChar != 'I' && nextChar != 'J' && nextChar != 'F' && nextChar != 'D' && nextChar != 'Z') { ++brackets; } } else { ++brackets; } } else if (buffer.charAt(i) == ']') { --brackets; } // new message if (brackets == 0) { messages.add(buffer.substring(start, i + 1)); start = i + 1; } } buffer.delete(0, start); // create the objects List<Object> objects = new ArrayList<Object>(); for (String message : messages) { try { Serializer serializer = getRPCSerializer(); ClientSerializationStreamReader reader = new ClientSerializationStreamReader(serializer); reader.prepareToRead(message); objects.add(reader.readObject()); } catch (RuntimeException e) { throw new SerializationException(e); } } return objects; }
From source file:org.restlet.client.engine.resource.GwtClientProxy.java
License:LGPL
/** * Creates an object stream reader.// w ww . j a v a2 s.c o m * * @param encoded * The encoded string to read. * @return A new object stream reader. */ public SerializationStreamReader createStreamReader(String encoded) throws SerializationException { ClientSerializationStreamReader clientSerializationStreamReader = new ClientSerializationStreamReader( serializer); if (encoded.startsWith("//OK") || encoded.startsWith("//EX")) { encoded = encoded.substring(4); } clientSerializationStreamReader.prepareToRead(encoded); return clientSerializationStreamReader; }
From source file:rocket.remoting.client.GwtSerializationCometClient.java
License:Apache License
/** * This factory method creates a reader which may be used to deserialize * incoming payloads.// www. j ava 2s. c o m * * @param serializedForm * @return * @throws SerializationException */ protected SerializationStreamReader createSerializationStreamReader(final String serializedForm) throws SerializationException { Checker.notEmpty("parameter:serializedForm", serializedForm); final Object proxy = this.createGwtRpcProxy(); if (false == GWT.isScript() && false == (proxy instanceof HasSerializer)) { this.throwRocketJarClasspathProblem(); } final HasSerializer serializerHost = (HasSerializer) proxy; final Serializer serializer = serializerHost.getSerializer(); final ClientSerializationStreamReader deserializer = new ClientSerializationStreamReader(serializer); deserializer.prepareToRead(serializedForm); return deserializer; }