本文整理汇总了Java中com.codename1.io.Util.writeObject方法的典型用法代码示例。如果您正苦于以下问题:Java Util.writeObject方法的具体用法?Java Util.writeObject怎么用?Java Util.writeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.io.Util
的用法示例。
在下文中一共展示了Util.writeObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* @see com.codename1.io.Externalizable
*/
public void externalize(DataOutputStream out) throws IOException {
/*
Note that ParseRelations are applied on ParseObjects and since only saved
ParseObjects are serialized by design, the only piece of information
needed to reconstruct the relation is the targetClass. However,
for completeness, we include other fields except the parent since
serializing the parent will result in an infinite loop. If there's
ever a usecase where a ParseRelation is deemed useful outside a ParseObject,
a smart way to store the parent would be implemented.
*/
Util.writeUTF(targetClass, out);
Util.writeUTF(key, out);
Util.writeObject(setToArray(addedObjects), out);
Util.writeObject(setToArray(removedObjects), out);
}
示例2: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* Serializes the contents of the ParseObject in a manner that complies with
* the {@link com.codename1.io.Externalizable} interface.
*
* @param out The data stream to serialize to.
* @throws IOException if any IO error occurs
* @throws ParseException if the object is {@link #isDirty() dirty}
*/
public void externalize(DataOutputStream out) throws IOException, ParseException {
if (isDirty()) {
throw new ParseException(ParseException.OPERATION_FORBIDDEN,
"A dirty ParseObject cannot be serialized to storage");
}
Util.writeUTF(getObjectId(), out);
Util.writeObject(getCreatedAt(), out);
Util.writeObject(getUpdatedAt(), out);
// Persist actual data
out.writeInt(keySet().size());
for (String key : keySet()) {
out.writeUTF(key);
Object value = get(key);
if (value instanceof ParseObject) {
value = ((ParseObject)value).asExternalizable();
} else if (ExternalizableJsonEntity.isExternalizableJsonEntity(value)) {
value = new ExternalizableJsonEntity(value);
}
Util.writeObject(value, out);
}
}
示例3: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void externalize(DataOutputStream out) throws IOException {
Map m = new HashMap();
m.put("sku", getSku());
m.put("expiryDate", getExpiryDate());
m.put("cancellationDate", getCancellationDate());
m.put("purchaseDate", getPurchaseDate());
m.put("orderData", getOrderData());
m.put("transactionId", getTransactionId());
m.put("quantity", getQuantity());
m.put("storeCode", getStoreCode());
m.put("internalId", getInternalId());
Util.writeObject(m, out);
}
示例4: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* Serializes ParseUser-specific data in addition to regular ParseObject data.
*
* @param out The data stream to serialize to.
* @throws IOException if any IO error occurs
* @throws ParseException if the object is {@link #isDirty() dirty}
* @see ParseObject#externalize(java.io.DataOutputStream)
*/
@Override
public void externalize(DataOutputStream out) throws IOException, ParseException {
super.externalize(out);
Util.writeUTF(sessionToken, out);
Util.writeUTF(password, out);
Util.writeObject(this.equals(current), out);
}
示例5: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* @see com.codename1.io.Externalizable
*/
public void externalize(DataOutputStream out) throws IOException {
out.writeBoolean(isDirty());
Util.writeUTF(getEndPoint(), out);
Util.writeUTF(getName(), out);
Util.writeUTF(getUrl(), out);
Util.writeUTF(getContentType(), out);
Util.writeObject(data, out);
}
示例6: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* @see com.codename1.io.Externalizable
*/
public void externalize(DataOutputStream out) throws IOException {
Util.writeUTF(type.toString(), out);
if (type == EJsonEntityType.JSON_ARRAY) {
Util.writeObject(ParseDecoder.convertJSONArrayToList((JSONArray)object), out);
} else if (type == EJsonEntityType.JSON_OBJECT) {
Util.writeObject(ParseDecoder.convertJSONObjectToMap((JSONObject)object), out);
}
}
示例7: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
@Override
public void externalize(DataOutputStream out) throws IOException {
ArrayList<Map> data = new ArrayList<Map>();
for (int i = 0; i < getSize(); i++)
{
data.add(getItemAt(i));
}
Util.writeObject(id, out);
Util.writeUTF(name, out);
Util.writeObject(access, out);
Util.writeObject(offline_available, out);
Util.writeObject(data, out);
}
示例8: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
@Override
public void externalize(DataOutputStream out) throws IOException {
Util.writeUTF(username, out);
Util.writeUTF(token, out);
Util.writeUTF(firstName, out);
Util.writeUTF(lastName, out);
Util.writeObject(languages, out);
}
示例9: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
@Override
public void externalize(DataOutputStream out) throws IOException {
Util.writeObject(previousQueue, out);
Util.writeObject(current, out);
Util.writeObject(userQueue, out);
Util.writeObject(nextQueue, out);
Util.writeObject(nextShuffledQueue, out);
}
示例10: writeResponse
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* Returns an OK response to the client
* @param resp the response object
* @param def the method definition
* @param response the result from the method
*/
public static void writeResponse(HttpServletResponse resp, WSDefinition def, Externalizable response) throws IOException {
resp.setStatus(HttpServletResponse.SC_OK);
DataOutputStream dos = new DataOutputStream(resp.getOutputStream());
Util.writeObject(response, dos);
dos.close();
}
示例11: buildRequestBody
import com.codename1.io.Util; //导入方法依赖的package包/类
protected void buildRequestBody(OutputStream os) throws IOException {
DataOutputStream d = new DataOutputStream(os);
d.writeInt(storageQueue.size());
d.writeUTF(CloudPersona.getCurrentPersona().getToken());
d.writeUTF(Display.getInstance().getProperty("package_name", null));
d.writeUTF(Display.getInstance().getProperty("built_by_user", null));
for(int iter = 0 ; iter < storageQueue.size() ; iter++) {
Object e = storageQueue.elementAt(iter);
if(e instanceof String) {
// delete operation
d.writeByte(1);
d.writeUTF((String)e);
} else {
CloudObject cl = (CloudObject)e;
if(cl.getCloudId() == null) {
// insert operation
d.writeByte(2);
d.writeInt(cl.getAccessPermissions());
Util.writeObject(cl.getValues(), d);
} else {
// update operation
d.writeByte(3);
d.writeUTF(cl.getCloudId());
d.writeLong(cl.getLastModified());
Util.writeObject(cl.getValues(), d);
}
}
}
d.writeInt(1);
}
示例12: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void externalize(DataOutputStream out) throws IOException {
Util.writeUTF(cloudId, out);
out.writeBoolean(owner);
out.writeByte(getAccessPermissions());
out.writeLong(lastModified);
out.writeInt(status);
Util.writeObject(values, out);
}
示例13: externalize
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* @see com.codename1.io.Externalizable
*/
public void externalize(DataOutputStream out) throws IOException {
Util.writeObject(getLatitude(), out);
Util.writeObject(getLongitude(), out);
}
示例14: asExternalizable
import com.codename1.io.Util; //导入方法依赖的package包/类
/**
* Returns an externalizable object for serialization of this business object, unlike regular
* externalizables this implementation is robust to changes, additions and removals of
* properties
* @return an externalizable instance
*/
public Externalizable asExternalizable() {
return new Externalizable() {
public int getVersion() {
return 1;
}
public void externalize(DataOutputStream out) throws IOException {
out.writeInt(getSize());
for(PropertyBase b : PropertyIndex.this) {
out.writeUTF(b.getName());
if(b instanceof ListProperty) {
out.writeByte(2);
Util.writeObject(((ListProperty)b).asList(), out);
continue;
}
if(b instanceof MapProperty) {
out.writeByte(3);
Util.writeObject(((MapProperty)b).asMap(), out);
continue;
}
if(b instanceof Property) {
out.writeByte(1);
Util.writeObject(((Property)b).get(), out);
continue;
}
}
}
public void internalize(int version, DataInputStream in) throws IOException {
int size = in.readInt();
for(int iter = 0 ; iter < size ; iter++) {
String pname = in.readUTF();
int type = in.readByte();
Object data = Util.readObject(in);
PropertyBase pb = get(pname);
switch(type) {
case 1: // Property
if(pb instanceof Property) {
((Property)pb).set(data);
}
break;
case 2: // ListProperty
if(pb instanceof ListProperty) {
((ListProperty)pb).setList((List)data);
}
break;
case 3: // MapProperty
if(pb instanceof MapProperty) {
((MapProperty)pb).setMap((Map)data);
}
break;
}
}
}
public String getObjectId() {
return getName();
}
};
}