Back to project page trivial-password.
The source code is released under:
MIT License
If you think the Android project trivial-password listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.hbabcock.trivialpassword; //from w w w . j av a 2 s.c om import java.util.ArrayList; import java.util.UUID; import org.json.JSONException; import org.json.JSONObject; /* * All the account data is stored in mData. The first element * is the account name, the second is the username, the third * is the password and the rest is extr account data. */ public class Account { private static final String DELIMITER = "\u001F"; private static final String JSON_DATA = "data"; private static final Integer nFields = 6; private UUID mId; private ArrayList<String> mData; public Account(){ mId = UUID.randomUUID(); mData = new ArrayList<String>(); for (int j = 0;j < nFields; j++){ mData.add(""); } } public Account(ArrayList<String> data){ mId = UUID.randomUUID(); mData = data; } public Account (JSONObject json) throws JSONException { setFromString(json.getString(JSON_DATA)); } public Account (String s){ String[] sData = s.split(DELIMITER, -1); mId = UUID.fromString(sData[0]); mData = new ArrayList<String>(); for(int i=1;i<sData.length;i++){ mData.add(sData[i]); } } public Account(UUID id, ArrayList<String> data){ mId = id; mData = data; } public String getAccount(){ return mData.get(0); } public ArrayList<String> getData(){ return mData; } public UUID getId(){ return mId; } public String getUsername(){ return mData.get(1); } public void setFromString(String s){ String[] sData = s.split(DELIMITER, -1); mId = UUID.fromString(sData[0]); ArrayList<String> data = new ArrayList<String>(); for(int i=1;i<sData.length;i++){ data.add(sData[i]); } mData = data; } public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put(JSON_DATA, toString()); return json; } @Override public String toString(){ StringBuilder accountData = new StringBuilder(); accountData.append(mId.toString()); accountData.append(DELIMITER); for(String datum : mData){ accountData.append(datum); accountData.append(DELIMITER); } accountData.setLength(accountData.length() - DELIMITER.length()); return accountData.toString(); } }