Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 房间数据库使用转换器保存和检索对象_Java_Android_Type Conversion_Android Room_Room - Fatal编程技术网

Java 房间数据库使用转换器保存和检索对象

Java 房间数据库使用转换器保存和检索对象,java,android,type-conversion,android-room,room,Java,Android,Type Conversion,Android Room,Room,当我试图使用rooms数据库保存对象时,数据插入成功。在检索数据时,对象中的一个值(对象)被检索为数组。将数组转换回对象无效。已正确检索根对象中的其他字符串和整数值 保存的对象: [[F@6c173ab 检索到的对象: [[0.0066505815, 其中,0.05939757,0.058359599757,0.05835959599757,0.0583595959570,0.0583594040407,0.058320906,0.058320906,0.0 0 0 0 0.0183234040

当我试图使用rooms数据库保存对象时,数据插入成功。在检索数据时,对象中的一个值(对象)被检索为数组。将数组转换回对象无效。已正确检索根对象中的其他字符串和整数值

保存的对象:

[[F@6c173ab

检索到的对象:

[[0.0066505815, 其中,0.05939757,0.058359599757,0.05835959599757,0.0583595959570,0.0583594040407,0.058320906,0.058320906,0.0 0 0 0 0.0183234040404040830 0.0 0 0 0 0.018383979797970,0.0 0.0583979797979757575757,0 0.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0583404040404079399,0.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.058495959595959595959595950 0 0 0 0 0 0,0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 031670928,0.004658082, -0.042408537, -0.08871324, -0.13611381, 0.0048175915, 0.060110737, -0.05661096, -0.004599247, 0.02567487, -0.14492176, 0.41225138, 0.037969578, -0.0060184584, 0.16407079, -0.007605861, -0.004265492, -0.0011223844, 0.006605887, -0.008077469, 0.0015253898, -0.10189122, 0.050602783, 0.0058309403, 0.057144053, 0.07865115, -0.0022470118, 0.005851626, -0.0.39484884E-4,0.02980-4,0.0117817828287,0.01178287,0.01178287,0.01178287,0.0 0 0.0178787841412,0.01178287,0.0 0.01787878287,0.0.017878414141417,0.0.01787878287,0.0178287,0.0178287,0 0.0178287,0.01787,0.0178287,0,0.0178287,0.01787,0.0178287,0,0.0178787,0 0 0.0178287,0,0,0,0.0178287,0,0,0.0178287,0,0.0178287,0,0,0 0 0 0 0 0.0178287,0,0 0,0,0 0 0 4,0.03005817,0.03其中包括0.08913908、0.08913908、0.08913908、0.08913908、0.0014652398、0.0014652971、0.00146465241419、0.0014652419、0.009252578712、0.009252578712、0.0092525712、0.032525712、0.00925712、0.00925712、0.00925712、0.0325712、0-0.0.0325712、0-0.0325712、0-0.0.030.03万万万万万万万万万万万万万万万万万万万万万万万万万万零零零零零零零零零零零零零零零零零零五五五五五五五五五五五五五五五五二二二二七七七二二二二二二二二二二二二二、0 0 0 0 25107688,0.007046912,0.00其中,0.0071865367,0.17709937,0.1777,0.1779,0.1779,0.1779,0.1779,0.1779,0.177279 26106,0.0041772726106,0.0041772844,0.004177284,0.2441414141414141414141412844,0.41772844,0.4141772844,0.414141414141412844,0,0.24414141414141412844,0,0 0.247,0.24772844,0,0,0.244141414141414141412844,0,0,0,0,0.247,0,0.41414141417844,0,0,0,0 0.414141414141414141414141412844,0四四四四四四四四四四四四四四四四四3139,-7.1395264E-4,0.05255035,6.5167714E-4,0.096607,0.09660987,0.05955607,0.059556033,0.0 0 0.059556033,0.0011481484445,0.0 0 0.0 0 0.0 0 0.148747474224224224224242424242424242240,0.0.0.0.0.0.0 0 0.0 0.0 0 0 0.0 0 0 0 0.0.0 0 0 0 0 0 0 0 0 0 0 0 0.6607 7 7,0 0 0 0 0.0 0 0 0 0 0 0 0 0 0 0.6607 7 7 7 7,0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6607 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7,0 0.0019819727,0.00459其中,0.005658582,0.026658582,0.004545382543,0.004545382543,0.00454545382543,0.005353815856,0.00535856,0.0053815856,0.00153585856,0.005353585858585856,0.01924646464646464646467,0.019246464646464646467,7,7,0.0.001924646464646467,7,7,7,0.0.00464646467,7,7,7,0.0.66464646467,7,7,7,7,7,7,7,7,7,0.0.0.0.6646464646467,7,7,7,7,7,7,7,7,7,7,7,7,7,9-9-9-9,9,5,-0.06919885,-0.022822084、-0.009733031、0.0038881213、0.2372824、0.15371381、-0.0267819、-0.048720658、0.029161548、-0.16049597、0.023316571、0.0020684062]]

这是我使用的类型转换器

@TypeConverter
public static String fromRecognition(SimilarityClassifier.Recognition recognition) {
    if (recognition == null) {
        return (null);
    }
    Gson gson = new Gson();
    Type type = new TypeToken<SimilarityClassifier.Recognition>() {
    }.getType();
    String json = gson.toJson(recognition, type);
    return json;
}

@TypeConverter
public static SimilarityClassifier.Recognition toRecognition(String recognitionString) {
    if (recognitionString == null) {
        return (null);
    }
    Gson gson = new Gson();
    Type type = new TypeToken<SimilarityClassifier.Recognition>() {
    }.getType();
    SimilarityClassifier.Recognition recognition = gson.fromJson(recognitionString, type);
    return recognition;
}
相似分类。识别如下

公众阶级认可{

private final String id;
private final String title;
private final Float distance;
private Object extra;

private RectF location;
private Integer color;
private Bitmap crop;

public Recognition(
        final String id, final String title, final Float distance, final RectF location) {
    this.id = id;
    this.title = title;
    this.distance = distance;
    this.location = location;
    this.color = null;
    this.extra = null;
    this.crop = null;
}

public String getId() {
    return id;
}

public String getTitle() {
    return title;
}

public Float getDistance() {
    return distance;
}

public RectF getLocation() {
    return new RectF(location);
}

public Bitmap getCrop() {
    return this.crop;
}

public Integer getColor() {
    return this.color;
}

public Object getExtra() {
    return this.extra;
}


public void setExtra(Object extra) {
    this.extra = extra;
}

public void setColor(Integer color) {
    this.color = color;
}

public void setLocation(RectF location) {
    this.location = location;
}

public void setCrop(Bitmap crop) {
    this.crop = crop;
}


@Override
public String toString() {
    String resultString = "";
    if (id != null) {
        resultString += "[" + id + "] ";
    }

    if (title != null) {
        resultString += title + " ";
    }

    if (distance != null) {
        resultString += String.format("(%.1f%%) ", distance * 100.0f);
    }

    if (location != null) {
        resultString += location + " ";
    }

    return resultString.trim();
}
}
如果其他任何人遇到此问题,请帮助

您能否共享
相似分类器的结构。识别
@vizsatiz我已在上面对其进行了更新
private final String id;
private final String title;
private final Float distance;
private Object extra;

private RectF location;
private Integer color;
private Bitmap crop;

public Recognition(
        final String id, final String title, final Float distance, final RectF location) {
    this.id = id;
    this.title = title;
    this.distance = distance;
    this.location = location;
    this.color = null;
    this.extra = null;
    this.crop = null;
}

public String getId() {
    return id;
}

public String getTitle() {
    return title;
}

public Float getDistance() {
    return distance;
}

public RectF getLocation() {
    return new RectF(location);
}

public Bitmap getCrop() {
    return this.crop;
}

public Integer getColor() {
    return this.color;
}

public Object getExtra() {
    return this.extra;
}


public void setExtra(Object extra) {
    this.extra = extra;
}

public void setColor(Integer color) {
    this.color = color;
}

public void setLocation(RectF location) {
    this.location = location;
}

public void setCrop(Bitmap crop) {
    this.crop = crop;
}


@Override
public String toString() {
    String resultString = "";
    if (id != null) {
        resultString += "[" + id + "] ";
    }

    if (title != null) {
        resultString += title + " ";
    }

    if (distance != null) {
        resultString += String.format("(%.1f%%) ", distance * 100.0f);
    }

    if (location != null) {
        resultString += location + " ";
    }

    return resultString.trim();
}