List of usage examples for java.lang Short toString
public static String toString(short s)
From source file:edu.cmu.mpcs.dashboard.TagViewer.java
void buildTagViews(NdefMessage[] msgs) { if (msgs == null || msgs.length == 0) { return;/*from w w w . j a v a 2s .c om*/ } LayoutInflater inflater = LayoutInflater.from(this); // LinearLayout content = mTagContent; // Clear out any old views in the content area, for example if // you scan // two tags in a row. // content.removeAllViews(); // Parse the first message in the list // Build views for all of the sub records Log.i("TEST", "test"); List<ParsedNdefRecord> records = NdefMessageParser.parse(msgs[0]); NdefRecord[] ndefRecords = msgs[0].getRecords(); short tnf = ndefRecords[0].getTnf(); Log.d("RECORD", "tnf is : " + Short.toString(tnf)); byte[] type = ndefRecords[0].getType(); byte[] standard = NdefRecord.RTD_TEXT; System.out.println("printing what we got in the message"); for (byte theByte : type) { System.out.println(Integer.toHexString(theByte)); Log.d("RECORD", Integer.toHexString(theByte)); } System.out.println("printing what the actual val is "); for (byte theByte : standard) { System.out.println(Integer.toHexString(theByte)); Log.d("RECORD", Integer.toHexString(theByte)); } if (ndefRecords[0].getType().equals(standard)) Log.d("RECORD", " type is : RTD_TXT"); else if (ndefRecords[0].getType().equals(NdefRecord.RTD_URI)) Log.d("RECORD", " type is : RTD_URI"); else Log.d("RECORD", " type is : none of the 2"); final int size = records.size(); for (int i = 0; i < size; i++) { ParsedNdefRecord record = records.get(i); Log.i("RECORD", record.toString()); String text; if (record instanceof TextRecord) { TextRecord t = (TextRecord) record; text = t.getText(); } else { UriRecord t = (UriRecord) record; text = t.getUri().toString(); } Log.d("WIFI", text); /* * At this point we have obtained the name of the profile . We * should not append .txt and see if the file exists in the * /mnt/Profile folder. * * If it does exist, then we read the file, and apply various * settings * * If it does note exists, then we show an error message indicating * that the user does not have a profile corresponding to this TAG. * Alternatively: We can take him to the create TAG activity where * he can create a new TAG with this name. */ String contents[] = text.split("#"); String filename = null; if (contents.length > 1) { String readHash = contents[0]; filename = contents[1]; Log.d("TAG_VIEWER", "readHash: " + readHash); Log.d("TAG_VIEWER", "filename: " + filename); if (readHash.equals(Utility.hashOfId)) { Log.d("TAG_VIEWER", "Hash Valid"); File root = Environment.getExternalStorageDirectory(); String path = root + "/Profiles/" + Utility.userUID + "/"; String filePath = path + filename + ".txt"; String settingString = ""; boolean exists = (new File(path).exists()); if (exists) { Log.d("TAG_VIEWER", "Found file:" + filePath); /* * Parse the contents of the file, and apply settings */ try { FileReader logReader = new FileReader(filePath); BufferedReader in = new BufferedReader(logReader); try { settingString = in.readLine(); Log.d("TAG_VIEWER", "In " + filePath + " settingString: " + settingString); } catch (IOException e) { // TODO Auto-generated catch block Log.d("TAG_VIEWER", " read(buf) exception"); e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block Log.d("TAG_VIEWER", "FileReader exception"); e.printStackTrace(); } /* * One call for each setting that we support */ StringBuilder returnVal = new StringBuilder(); returnVal.append(wifiSetting(settingString)); returnVal.append(bluetoothSetting(settingString)); returnVal.append(ringerSetting(settingString)); launchmusicSetting(settingString); returnVal.append(alarmSetting(settingString)); fbSetting(settingString); Log.d("TAG_VIEWER", "the toast should be : " + returnVal.toString()); Context context = getApplicationContext(); CharSequence toastMessage = returnVal; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, toastMessage, duration); toast.show(); } else { /* * Give the user the option of creating a new tag or * ignoring this tag */ } } else { Log.d("TAG_VIEWER", "Hash InValid"); int duration = Toast.LENGTH_LONG; CharSequence msg = "Authentication failure.This tag does not belong to you"; Toast toast = Toast.makeText(TagViewer.this, msg, duration); toast.show(); finish(); // return; } } else { // public tag Log.d("PUBLIC_TAG", "PUBLIC_TAG"); } // For Vibrate mode // /** Sending an SMS to a particular number **/ // Intent intent = new // Intent(Intent.ACTION_VIEW, // Uri.parse("sms:" + "5189515772")); // intent.putExtra("sms_body", // "Hi This is a test message"); // startActivity(intent); /** Toggle Airplane mode **/ // Context context = getApplicationContext(); // boolean isEnabled = // Settings.System.getInt(this.getApplicationContext().getContentResolver(), // Settings.System.AIRPLANE_MODE_ON, 0) == 1; // Settings.System.putInt(context.getContentResolver(),Settings.System.AIRPLANE_MODE_ON,isEnabled // ? 0 : 1); // Intent intent = new // Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); // intent.putExtra("state", !isEnabled); // sendBroadcast(intent); /** Launching the browser **/ // String url = "http://www.google.com"; // Intent intent = new // Intent(Intent.ACTION_VIEW); // intent.setData(Uri.parse(url)); // startActivity(intent); /** Check into Facebook **/ // Bundle params = new Bundle(); // // //String access_token = // AndroidDashboardActivity.mPrefs.getString("access_token", // null); // //params.putString("access_token", access_token); // params.putString("place", "203682879660695"); // YOUR PLACE // ID // params.putString("Message","I m here in this place"); // JSONObject coordinates = new JSONObject(); // try // { // coordinates.put("latitude", 40.756); // coordinates.put("longitude", -73.987); // } // catch (JSONException e) // { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // params.putString("coordinates",coordinates.toString()); // JSONArray frnd_data=new JSONArray(); // params.putString("tags", "waves.mpcs@gmail.com");//where xx // indicates the User Id // String response; // try // { // response = facebook.request("me/checkins", params, "POST"); // Log.d("Response",response); // } // catch (FileNotFoundException e) // { // // TODO Auto-generated catch block // e.printStackTrace(); // } // catch (MalformedURLException e) // { // // TODO Auto-generated catch block // e.printStackTrace(); // } // catch (IOException e) // { // // TODO Auto-generated catch block // e.printStackTrace(); // } // //Log.d("Response",response); /* * TODO: Hashing TODO: Facebook Auth TODO: File Storage (Profile * Storage) TODO: Sample Profiles TODO: Social Network Check in * TODO: Alarms TODO: Airplane Mode (Enabling NFC while switching to * Airplane mode) TODO: NFC Launcher List (Market App) TODO: UI */ // content.addView(record.getView(this, inflater, content, i)); // inflater.inflate(R.layout.tag_divider, content, true); } }
From source file:com.skratchdot.electribe.model.esx.provider.SongItemProvider.java
/** * This returns the column text for the adapted class. * <!-- begin-user-doc -->//w ww. java2 s . c o m * <!-- end-user-doc --> */ @Override public String getColumnText(Object object, int columnIndex) { switch (columnIndex) { // Esx# case 0: return ((Song) object).getSongNumberCurrent().toString(); // Orig# case 1: return ((Song) object).getSongNumberOriginal().toString(); // Name case 2: return ((Song) object).getName(); // Tempo case 3: return Float.toString(((Song) object).getTempo().getValue()); // TempoLock case 4: return ((Song) object).getTempoLock().getLiteral(); // Length case 5: return ((Song) object).getSongLength().getLiteral(); // MuteHold case 6: return ((Song) object).getMuteHold().getLiteral(); // NextSong case 7: return ((Song) object).getNextSongNumber().getLiteral(); // NumOfEvents case 8: return Short.toString(((Song) object).getNumberOfSongEventsCurrent()); default: return getText(object); } }
From source file:com.netspective.axiom.policy.AnsiDatabasePolicy.java
public void reverseEngineer(Writer writer, Connection conn, String catalog, String schemaPattern) throws IOException, SQLException { Map dataTypesMap = prepareJdbcTypeInfoMap(); DatabaseMetaData dbmd = conn.getMetaData(); TextUtils textUtils = TextUtils.getInstance(); writer.write("<?xml version=\"1.0\"?>\n\n"); writer.write("<!-- Reverse engineered by Axiom\n"); writer.write(" driver: " + dbmd.getDriverName() + "\n"); writer.write(" driver-version: " + dbmd.getDriverVersion() + "\n"); writer.write(" product: " + dbmd.getDatabaseProductName() + "\n"); writer.write(" product-version: " + dbmd.getDatabaseProductVersion() + "\n"); writer.write(" available catalogs:"); ResultSet rs = null;//from w w w. ja va2 s. c o m try { rs = dbmd.getCatalogs(); while (rs.next()) { writer.write(" " + rs.getObject(1).toString()); } } finally { if (rs != null) rs.close(); } writer.write("\n"); writer.write(" available schemas:"); try { rs = dbmd.getSchemas(); while (rs.next()) { writer.write(" " + rs.getObject(1).toString()); } } finally { if (rs != null) rs.close(); } writer.write("\n"); writer.write("-->\n\n"); writer.write("<component xmlns:xdm=\"http://www.netspective.org/Framework/Commons/XMLDataModel\">\n"); writer.write(" <xdm:include resource=\"com/netspective/axiom/conf/axiom.xml\"/>\n"); writer.write(" <schema name=\"" + catalog + "." + schemaPattern + "\">\n"); Map dbmdTypeInfoByName = new HashMap(); Map dbmdTypeInfoByJdbcType = new HashMap(); ResultSet typesRS = null; try { typesRS = dbmd.getTypeInfo(); while (typesRS.next()) { int colCount = typesRS.getMetaData().getColumnCount(); Object[] typeInfo = new Object[colCount]; for (int i = 1; i <= colCount; i++) typeInfo[i - 1] = typesRS.getObject(i); dbmdTypeInfoByName.put(typesRS.getString(1), typeInfo); dbmdTypeInfoByJdbcType.put(new Integer(typesRS.getInt(2)), typeInfo); } } finally { if (typesRS != null) typesRS.close(); } ResultSet tables = null; try { tables = dbmd.getTables(catalog, schemaPattern, null, new String[] { "TABLE" }); while (tables.next()) { String tableNameOrig = tables.getString(3); String tableName = textUtils.fixupTableNameCase(tableNameOrig); writer.write(" <table name=\"" + tableName + "\">\n"); Map primaryKeys = new HashMap(); ResultSet pkRS = null; try { pkRS = dbmd.getPrimaryKeys(null, null, tableNameOrig); while (pkRS.next()) { primaryKeys.put(pkRS.getString(4), pkRS.getString(5)); } } catch (Exception e) { // driver may not support this function } finally { if (pkRS != null) pkRS.close(); } Map fKeys = new HashMap(); ResultSet fkRS = null; try { fkRS = dbmd.getImportedKeys(null, null, tableNameOrig); while (fkRS.next()) { fKeys.put(fkRS.getString(8), textUtils.fixupTableNameCase(fkRS.getString(3)) + "." + fkRS.getString(4).toLowerCase()); } } catch (Exception e) { // driver may not support this function } finally { if (fkRS != null) fkRS.close(); } // we keep track of processed columns so we don't duplicate them in the XML Set processedColsMap = new HashSet(); ResultSet columns = null; try { columns = dbmd.getColumns(null, null, tableNameOrig, null); while (columns.next()) { String columnNameOrig = columns.getString(4); if (processedColsMap.contains(columnNameOrig)) continue; processedColsMap.add(columnNameOrig); String columnName = columnNameOrig.toLowerCase(); writer.write(" <column name=\"" + columnName + "\""); try { if (fKeys.containsKey(columnNameOrig)) writer.write(" lookup-ref=\"" + fKeys.get(columnNameOrig) + "\""); else { short jdbcType = columns.getShort(5); String dataType = (String) dataTypesMap.get(new Integer(jdbcType)); if (dataType == null) dataType = Short.toString(jdbcType); writer.write(" type=\"" + dataType + "\""); } if (primaryKeys.containsKey(columnNameOrig)) writer.write(" primary-key=\"yes\""); if (columns.getString(18).equals("NO")) writer.write(" required=\"yes\""); String defaultValue = columns.getString(13); if (defaultValue != null) writer.write(" default=\"" + defaultValue + "\""); String remarks = columns.getString(12); if (remarks != null) writer.write(" descr=\"" + remarks + "\""); } catch (Exception e) { } writer.write("/>\n"); } } finally { if (columns != null) columns.close(); } writer.write(" </table>\n"); } } finally { tables.close(); } writer.write(" </schema>\n"); writer.write("</component>"); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmISOCountryHPKey.java
public String toString() { String ret = "<CFCrmISOCountryHPKey" + " RequiredId=" + "\"" + Short.toString(getRequiredId()) + "\"" + " RequiredRevision=\"" + Integer.toString(getRequiredRevision()) + "\"" + "/>"; return (ret); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmISOCurrencyHPKey.java
public String toString() { String ret = "<CFCrmISOCurrencyHPKey" + " RequiredId=" + "\"" + Short.toString(getRequiredId()) + "\"" + " RequiredRevision=\"" + Integer.toString(getRequiredRevision()) + "\"" + "/>"; return (ret); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmISOLanguageHPKey.java
public String toString() { String ret = "<CFCrmISOLanguageHPKey" + " RequiredId=" + "\"" + Short.toString(getRequiredId()) + "\"" + " RequiredRevision=\"" + Integer.toString(getRequiredRevision()) + "\"" + "/>"; return (ret); }
From source file:com.alibaba.citrus.service.requestcontext.support.ValueListSupport.java
/** * ???/? * * @param value ? */ public void addValue(short value) { addValue(Short.toString(value)); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmAuditActionHPKey.java
public String toString() { String ret = "<CFCrmAuditActionHPKey" + " RequiredAuditActionId=" + "\"" + Short.toString(getRequiredAuditActionId()) + "\"" + " RequiredRevision=\"" + Integer.toString(getRequiredRevision()) + "\"" + "/>"; return (ret); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmISOTimezoneHPKey.java
public String toString() { String ret = "<CFCrmISOTimezoneHPKey" + " RequiredISOTimezoneId=" + "\"" + Short.toString(getRequiredISOTimezoneId()) + "\"" + " RequiredRevision=\"" + Integer.toString(getRequiredRevision()) + "\"" + "/>"; return (ret); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmURLProtocolHPKey.java
public String toString() { String ret = "<CFCrmURLProtocolHPKey" + " RequiredURLProtocolId=" + "\"" + Short.toString(getRequiredURLProtocolId()) + "\"" + " RequiredRevision=\"" + Integer.toString(getRequiredRevision()) + "\"" + "/>"; return (ret); }