SystemModel.java
Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2005-2013 Team XBMC
00003  *      http://xbmc.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with XBMC Remote; see the file license.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 package org.xbmc.android.jsonrpc.api.model;
00022 
00023 import android.os.Parcel;
00024 import android.os.Parcelable;
00025 import java.util.ArrayList;
00026 import java.util.Arrays;
00027 import java.util.HashSet;
00028 import java.util.List;
00029 import java.util.Set;
00030 import org.codehaus.jackson.JsonNode;
00031 import org.codehaus.jackson.node.ArrayNode;
00032 import org.codehaus.jackson.node.ObjectNode;
00033 import org.xbmc.android.jsonrpc.api.AbstractModel;
00034 
00035 public final class SystemModel {
00036 
00043         public static class PropertyValue extends AbstractModel {
00044                 public final static String API_TYPE = "System.Property.Value";
00045 
00046                 // field names
00047                 public static final String CANHIBERNATE = "canhibernate";
00048                 public static final String CANREBOOT = "canreboot";
00049                 public static final String CANSHUTDOWN = "canshutdown";
00050                 public static final String CANSUSPEND = "cansuspend";
00051 
00052                 // class members
00053                 public final Boolean canhibernate;
00054                 public final Boolean canreboot;
00055                 public final Boolean canshutdown;
00056                 public final Boolean cansuspend;
00057 
00064                 public PropertyValue(Boolean canhibernate, Boolean canreboot, Boolean canshutdown, Boolean cansuspend) {
00065                         this.canhibernate = canhibernate;
00066                         this.canreboot = canreboot;
00067                         this.canshutdown = canshutdown;
00068                         this.cansuspend = cansuspend;
00069                 }
00070 
00075                 public PropertyValue(JsonNode node) {
00076                         canhibernate = parseBoolean(node, CANHIBERNATE);
00077                         canreboot = parseBoolean(node, CANREBOOT);
00078                         canshutdown = parseBoolean(node, CANSHUTDOWN);
00079                         cansuspend = parseBoolean(node, CANSUSPEND);
00080                 }
00081 
00082                 @Override
00083                 public JsonNode toJsonNode() {
00084                         final ObjectNode node = OM.createObjectNode();
00085                         node.put(CANHIBERNATE, canhibernate);
00086                         node.put(CANREBOOT, canreboot);
00087                         node.put(CANSHUTDOWN, canshutdown);
00088                         node.put(CANSUSPEND, cansuspend);
00089                         return node;
00090                 }
00091 
00097                 static List<PropertyValue> getSystemModelPropertyValueList(JsonNode node, String key) {
00098                         if (node.has(key)) {
00099                                 final ArrayNode a = (ArrayNode)node.get(key);
00100                                 final List<PropertyValue> l = new ArrayList<PropertyValue>(a.size());
00101                                 for (int i = 0; i < a.size(); i++) {
00102                                         l.add(new PropertyValue((JsonNode)a.get(i)));
00103                                 }
00104                                 return l;
00105                         }
00106                         return new ArrayList<PropertyValue>(0);
00107                 }
00108 
00114                 @Override
00115                 public void writeToParcel(Parcel parcel, int flags) {
00116                         parcel.writeInt(canhibernate ? 1 : 0);
00117                         parcel.writeInt(canreboot ? 1 : 0);
00118                         parcel.writeInt(canshutdown ? 1 : 0);
00119                         parcel.writeInt(cansuspend ? 1 : 0);
00120                 }
00121 
00125                 protected PropertyValue(Parcel parcel) {
00126                         canhibernate = parcel.readInt() == 1;
00127                         canreboot = parcel.readInt() == 1;
00128                         canshutdown = parcel.readInt() == 1;
00129                         cansuspend = parcel.readInt() == 1;
00130                 }
00131 
00135                 public static final Parcelable.Creator<PropertyValue> CREATOR = new Parcelable.Creator<PropertyValue>() {
00136                         @Override
00137                         public PropertyValue createFromParcel(Parcel parcel) {
00138                                 return new PropertyValue(parcel);
00139                         }
00140                         @Override
00141                         public PropertyValue[] newArray(int n) {
00142                                 return new PropertyValue[n];
00143                         }
00144                 };
00145 
00146                 @Override
00147                 public int describeContents() {
00148                         return 0;
00149                 }
00150         }
00151 
00155         public interface PropertyName {
00156 
00157                 public final String CANSHUTDOWN = "canshutdown";
00158                 public final String CANSUSPEND = "cansuspend";
00159                 public final String CANHIBERNATE = "canhibernate";
00160                 public final String CANREBOOT = "canreboot";
00161 
00162                 public final static Set<String> values = new HashSet<String>(Arrays.asList(CANSHUTDOWN, CANSUSPEND, CANHIBERNATE, CANREBOOT));
00163         }
00164 }


smarthome_media_kodi_driver
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Thu Jun 6 2019 21:03:49