serializable

Can you override the stream writers in scala @serializable objects?

亡梦爱人 提交于 2019-11-30 07:27:21
I now understand that scala @serializable objects can be used the same as a Java Serializable object. In a Java Serializable object there are methods you can override to change how the object streams: writeObject(ObjectOutputStream) / readObject(ObjectOutputStream). Can you override or inject methods into a scala @serializable object allowing you to change how the object serializes? Yes, you can use the same methods in Scala as in Java: @throws(classOf[IOException]) private def writeObject(out: ObjectOutputStream): Unit = // ... @throws(classOf[IOException]) private def readObject(in:

Redis Serialization and Deserialization

痞子三分冷 提交于 2019-11-30 05:25:22
I have noticed that some of my serialized objects stored in Redis have problems deserializing. This typically occurs when I make changes to the object class being stored in Redis. I want to understand the problem so that I can have a clear design for a solution. My question is, what causes deserialization problems? Would a removal of a public/private property cause a problem? Adding new properties, perhaps? Would a adding a new function to the class create problems? How about more constructors? In my serialized object, I have a property Map, what if I change (updated some properties, added

Who actually implements serializable methods?

有些话、适合烂在心里 提交于 2019-11-30 04:54:10
I've been learning how to use Serializable . I know if I create a class 'A' with different variables who implements Serializable and I add Serializable to my class, it's also Serializable . But, who is actually implementing those two methods to serialize? Does Object take care of everything or different classes overloads them when necessary? The serialization is actually implemented in java.io.ObjectOutputStream (and java.io.ObjectInputStream) and some of its helper classes. In many cases, this built-in support is sufficient, and the developer simply needs to implement the marker interface

Android serializable problem

无人久伴 提交于 2019-11-30 02:59:07
问题 I created a class, which has several member variables, all of which are serializable... except one Bitmap! I tried to extend bitmap and implement serializable, not thinking Bitmap is a final class. I want to save the class (it basically forms the current state of a game) so a player can pick-up and load the game. The way I see it I have two options: 1) Find another way to save the game state. Any help here would be appreciated. 2) change the bitmap member variable to an int, say, and create a

Is there any way to disable ORMLite's check that a field declared with DataType.SERIALIZABLE implements Serializable?

房东的猫 提交于 2019-11-30 00:00:48
问题 Question title just about says it all. I have a field declared like this: @DatabaseField(canBeNull=false,dataType=DataType.SERIALIZABLE) List<ScheduleTriggerPredicate> predicates = Collections.emptyList(); Depending on context, predicates can either contain the empty list or an immutable list returned by Collections.unmodifiableList(List) with an ArrayList as its parameter. I therefore know that the object in question is serializable, but there is no way I can tell the compiler (and therefore

Java - Sending an object that points to a BufferedImage through a Socket

こ雲淡風輕ζ 提交于 2019-11-29 18:05:48
Me and a group of friends are working on a project in Java, and we need some help regarding sending objects through sockets. So far, we have achieved to send simple objects (ints, strings and whatnot) through sockets, using ObjectOutputStream and ObjectInputStream . However, we ran into a huge problem today (huge for us, anyway ^^) We have a tree structure, that we need to send from one PC to another. The problem is that, within each node of that tree, we have a reference to a BufferedImage and it's not serializable. We have been researching a lot today, and we found out that we can use

Usage of parceler (@Parcel) with Realm.io (Android)

谁都会走 提交于 2019-11-29 15:25:36
问题 I have the following code which produces the error: Error:Parceler: Unable to find read/write generator for type io.realm.Realm for io.realm.RealmObject.realm It was working all fine without extends RealmObject , however I want to use Realm to put to database easily. Is there a way to exlcude the RealmObject fields and just use the basic pojo fields for @Parcel? @Parcel public class Feed extends RealmObject{ int id; public String text; public String time_created; String time_modified; int

decodeByteArray and copyPixelsToBuffer not working. SkImageDecoder::Factory returned null

时光毁灭记忆、已成空白 提交于 2019-11-29 14:08:22
问题 I have a class TouchPoint which implements Serializable and because it contains Bitmap I wrote writeObject and readObject for that class: private void writeObject(ObjectOutputStream oos) throws IOException { long t1 = System.currentTimeMillis(); oos.defaultWriteObject(); if(_bmp!=null){ int bytes = _bmp.getWidth()*_bmp.getHeight()*4; ByteBuffer buffer = ByteBuffer.allocate(bytes); _bmp.copyPixelsToBuffer(buffer); byte[] array = buffer.array(); oos.writeObject(array); } Log.v("PaintFX",

Socket program to send and receive user defined objects not working

若如初见. 提交于 2019-11-29 08:43:25
I have a user defined class Message, whose object I would like to pass between the client and the server. The Message class is as follows: import java.io.Serializable; public class Message implements Serializable { String CorS; int data_id; int status_id; Integer value; boolean withdraw; public Message() { CorS = null; data_id = 0; status_id = 0; value = 0; withdraw = false; } public Message(String CorS, int data_id, int status_id, Integer value) { this.CorS = CorS; this.data_id = data_id; this.status_id = status_id; this.value = value; } public Message(boolean withdraw) { this.withdraw =

android: problem with Serializable object put into intent

旧街凉风 提交于 2019-11-29 07:35:31
Hi i have problem with a class i want to pass in an intent by putting it into the putExtras() Its serializable and the code looks like this: public abstract class ObjectA extends ArrayList<ObjectA> implements java.io.Serializable{...} public class ObjectB extends ObjectA {...} ... Bundle extras = new Bundle(); extras.putSerializable("blabla", ObjectB); intent.putExtras(extras); ... Object y = getIntent().getExtras().get("blabla"); the problem is, that y now is an ArrayList and no longer an ObjectB so i cant cast it.. if i change the code to public class ObjectB implements java.io.Serializable