Java Code Examples for java.lang.StringBuilder#toString()

The following examples show how to use java.lang.StringBuilder#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Graphs.java    From Java with MIT License 6 votes vote down vote up
/**
 * this gives a list of verticies in the graph and their adjacencies
 *
 * @return returns a string describing this graph
 */
@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    for (Vertex v : verticies) {
        sb.append("Vertex: ");
        sb.append(v.data);
        sb.append("\n");
        sb.append("Adjacent verticies: ");
        for (Vertex v2 : v.adjacentVerticies) {
            sb.append(v2.data);
            sb.append(" ");
        }
        sb.append("\n");
    }
    return sb.toString();
}
 
Example 2
Source File: DbFile.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
  Create a string that contains a representation of the content of
  a file for testing.
  @exception Exception Oops.
  */
public static String
stringFromFile(InputStream is)
	 throws Exception
{
	InputStreamReader isr = new InputStreamReader(is);
	BufferedReader br =
		new BufferedReader(isr);
	StringBuilder sb = new StringBuilder();
	String l;
	while((l = br.readLine()) != null) {
		sb.append(l);
		sb.append("<CR>");
	}
	is.close();
	return sb.toString();
}
 
Example 3
Source File: Utilities.java    From algorithms with MIT License 6 votes vote down vote up
public static String toString(int[][] a) {
    if (a == null) return "[[]]";
    StringBuilder b = new StringBuilder();

    b.append("\n[\n");
    for (int i = 0; i < a.length; i ++) {
        b.append("\t[");
        for (int j = 0; j < a[i].length; j ++) {
            b.append(a[i][j]);
            if (j < a[i].length - 1) b.append(", ");
        }
        b.append("]\n");
    }
    b.append("]");

    return b.toString();
}
 
Example 4
Source File: VrManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public String toLogString(SimpleDateFormat dateFormat) {
    String tab = "  ";
    String newLine = "\n";
    StringBuilder sb = new StringBuilder(dateFormat.format(new Date(timestamp)));
    sb.append(tab);
    sb.append("State changed to:");
    sb.append(tab);
    sb.append((enabled) ? "ENABLED" : "DISABLED");
    sb.append(newLine);
    if (enabled) {
        sb.append(tab);
        sb.append("User=");
        sb.append(userId);
        sb.append(newLine);
        sb.append(tab);
        sb.append("Current VR Activity=");
        sb.append((callingPackage == null) ? "None" : callingPackage.flattenToString());
        sb.append(newLine);
        sb.append(tab);
        sb.append("Bound VrListenerService=");
        sb.append((targetPackageName == null) ? "None"
                : targetPackageName.flattenToString());
        sb.append(newLine);
        if (defaultPermissionsGranted) {
            sb.append(tab);
            sb.append("Default permissions granted to the bound VrListenerService.");
            sb.append(newLine);
        }
    }
    return sb.toString();
}
 
Example 5
Source File: Base64.java    From android-unicode with MIT License 5 votes vote down vote up
public static String encode(byte[] data)
{
    char[] tbl = {
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
        'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
        'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
        'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };

    StringBuilder buffer = new StringBuilder();
    int pad = 0;
    for (int i = 0; i < data.length; i += 3) {

        int b = ((data[i] & 0xFF) << 16) & 0xFFFFFF;
        if (i + 1 < data.length) {
            b |= (data[i+1] & 0xFF) << 8;
        } else {
            pad++;
        }
        if (i + 2 < data.length) {
            b |= (data[i+2] & 0xFF);
        } else {
            pad++;
        }

        for (int j = 0; j < 4 - pad; j++) {
            int c = (b & 0xFC0000) >> 18;
            buffer.append(tbl[c]);
            b <<= 6;
        }
    }
    for (int j = 0; j < pad; j++) {
        buffer.append("=");
    }

    return buffer.toString();
}
 
Example 6
Source File: CompactStringsInitialCoder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void test(String expected, String actual) {
   if (!expected.equals(actual)) {
       StringBuilder sb = new StringBuilder();
       sb.append("Expected = ");
       sb.append(expected);
       sb.append(", actual = ");
       sb.append(actual);
       throw new IllegalStateException(sb.toString());
   }
}
 
Example 7
Source File: ImplicitStringConcat.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void test(String expected, String actual) {
   // Fingers crossed: String concat should work.
   if (!expected.equals(actual)) {
       StringBuilder sb = new StringBuilder();
       sb.append("Expected = ");
       sb.append(expected);
       sb.append(", actual = ");
       sb.append(actual);
       throw new IllegalStateException(sb.toString());
   }
}
 
Example 8
Source File: Utilities.java    From algorithms with MIT License 5 votes vote down vote up
public static String toString(int[] a) {
    if (a == null) return "[]";
    StringBuilder b = new StringBuilder();

    b.append("[");
    for (int i = 0; i < a.length; i ++) {
        b.append(a[i]);
        if (i < a.length - 1) b.append(", ");
    }
    b.append("]");

    return b.toString();
}
 
Example 9
Source File: PostDataFromSpark.java    From ecosys with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  // type is vertex or edge
  String type = args[0];
  // graph name
  String graphName = args[1];
  // ddl loading job name
  String loadingJobName = args[2];
  // file name declared in ddl loading job
  String fileName = args[3];
  // file separator
  String separator = args[4];
  // end of line charactor
  String endOfLineChar = args[5];
  // path to input data
  inputPath = args[6];

  postInfo = "ddl/" + graphName+ "?tag=" + loadingJobName + "&filename="
            + fileName + "&sep=" + separator + "&eol=" + endOfLineChar;

  // create a spark session
  SparkSession sc = SparkSession.builder().getOrCreate();

  StringBuilder sbData = new StringBuilder();
  List<Row> arrayList= new ArrayList<>();

  // read input file to spark
  Dataset<Row> dataInSpark = sc.read().csv(inputPath);
  arrayList = dataInSpark.collectAsList();

  // convert Dataset<Row> to string, which is the payload info to post into tigergraph
  for(Row cur : arrayList) {
    String tmp = cur.toString();
    sbData.append(tmp.substring(1, tmp.length() - 1) + "\n");

  }
  String data = sbData.toString();
  sendHTTPRequest(postInfo, data, type);
}
 
Example 10
Source File: MainActivity.java    From apps-script-mobile-addons with Apache License 2.0 5 votes vote down vote up
/**
 * Interpret an error response returned by the API and return a String
 * summary. The summary will include the general error message and
 * (in most cases) a stack trace.
 * @param op the Operation returning an error response
 * @return summary of error response, or null if Operation returned no
 *     error
 */
protected String getScriptError(Operation op) {
    if (op.getError() == null) {
        return null;
    }

    // Extract the first (and only) set of error details and cast as a
    // Map. The values of this map are the script's 'errorMessage' and
    // 'errorType', and an array of stack trace elements (which also
    // need to be cast as Maps).
    Map<String, Object> detail = op.getError().getDetails().get(0);
    List<Map<String, Object>> stacktrace =
            (List<Map<String, Object>>)detail.get("scriptStackTraceElements");

    StringBuilder sb =
            new StringBuilder(getString(R.string.script_error));
    sb.append(detail.get("errorMessage"));

    if (stacktrace != null) {
        // There may not be a stacktrace if the script didn't start
        // executing.
        sb.append(getString(R.string.script_error_trace));
        for (Map<String, Object> elem : stacktrace) {
            sb.append("\n  ");
            sb.append(elem.get("function"));
            sb.append(":");
            sb.append(elem.get("lineNumber"));
        }
    }
    sb.append("\n");
    return sb.toString();
}
 
Example 11
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
private void __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(final ArrayMap<String, ArrayList<AutofillHint>> _map) {
  final Set<String> __mapKeySet = _map.keySet();
  if (__mapKeySet.isEmpty()) {
    return;
  }
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT autofillHint,fieldTypeName FROM `AutofillHint` WHERE fieldTypeName IN (");
  final int _inputSize = __mapKeySet.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : __mapKeySet) {
    if (_item == null) {
      _stmt.bindNull(_argIndex);
    } else {
      _stmt.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_stmt);
  try {
    final int _itemKeyIndex = _cursor.getColumnIndex("fieldTypeName");
    if (_itemKeyIndex == -1) {
      return;
    }
    final int _cursorIndexOfMAutofillHint = _cursor.getColumnIndexOrThrow("autofillHint");
    final int _cursorIndexOfMFieldTypeName = _cursor.getColumnIndexOrThrow("fieldTypeName");
    while(_cursor.moveToNext()) {
      if (!_cursor.isNull(_itemKeyIndex)) {
        final String _tmpKey = _cursor.getString(_itemKeyIndex);
        ArrayList<AutofillHint> _tmpCollection = _map.get(_tmpKey);
        if (_tmpCollection != null) {
          final AutofillHint _item_1;
          final String _tmpMAutofillHint;
          _tmpMAutofillHint = _cursor.getString(_cursorIndexOfMAutofillHint);
          final String _tmpMFieldTypeName;
          _tmpMFieldTypeName = _cursor.getString(_cursorIndexOfMFieldTypeName);
          _item_1 = new AutofillHint(_tmpMAutofillHint,_tmpMFieldTypeName);
          _tmpCollection.add(_item_1);
        }
      }
    }
  } finally {
    _cursor.close();
  }
}
 
Example 12
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
private void __fetchRelationshipResourceIdHeuristicAscomExampleAndroidAutofillServiceModelResourceIdHeuristic(final ArrayMap<String, ArrayList<ResourceIdHeuristic>> _map) {
  final Set<String> __mapKeySet = _map.keySet();
  if (__mapKeySet.isEmpty()) {
    return;
  }
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT resourceIdHeuristic,packageName,fieldTypeName FROM `ResourceIdHeuristic` WHERE fieldTypeName IN (");
  final int _inputSize = __mapKeySet.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : __mapKeySet) {
    if (_item == null) {
      _stmt.bindNull(_argIndex);
    } else {
      _stmt.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_stmt);
  try {
    final int _itemKeyIndex = _cursor.getColumnIndex("fieldTypeName");
    if (_itemKeyIndex == -1) {
      return;
    }
    final int _cursorIndexOfMResourceIdHeuristic = _cursor.getColumnIndexOrThrow("resourceIdHeuristic");
    final int _cursorIndexOfMPackageName = _cursor.getColumnIndexOrThrow("packageName");
    final int _cursorIndexOfMFieldTypeName = _cursor.getColumnIndexOrThrow("fieldTypeName");
    while(_cursor.moveToNext()) {
      if (!_cursor.isNull(_itemKeyIndex)) {
        final String _tmpKey = _cursor.getString(_itemKeyIndex);
        ArrayList<ResourceIdHeuristic> _tmpCollection = _map.get(_tmpKey);
        if (_tmpCollection != null) {
          final ResourceIdHeuristic _item_1;
          final String _tmpMResourceIdHeuristic;
          _tmpMResourceIdHeuristic = _cursor.getString(_cursorIndexOfMResourceIdHeuristic);
          final String _tmpMPackageName;
          _tmpMPackageName = _cursor.getString(_cursorIndexOfMPackageName);
          final String _tmpMFieldTypeName;
          _tmpMFieldTypeName = _cursor.getString(_cursorIndexOfMFieldTypeName);
          _item_1 = new ResourceIdHeuristic(_tmpMResourceIdHeuristic,_tmpMFieldTypeName,_tmpMPackageName);
          _tmpCollection.add(_item_1);
        }
      }
    }
  } finally {
    _cursor.close();
  }
}
 
Example 13
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
@Override
public List<DatasetWithFilledAutofillFields> getDatasets(List<String> allAutofillHints) {
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT DISTINCT id, datasetName FROM FilledAutofillField, AutofillDataset WHERE AutofillDataset.id = FilledAutofillField.datasetId AND FilledAutofillField.fieldTypeName IN (");
  final int _inputSize = allAutofillHints.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : allAutofillHints) {
    if (_item == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_statement);
  try {
    final ArrayMap<String, ArrayList<FilledAutofillField>> _collectionFilledAutofillFields = new ArrayMap<String, ArrayList<FilledAutofillField>>();
    final int _cursorIndexOfMId = _cursor.getColumnIndexOrThrow("id");
    final int _cursorIndexOfMDatasetName = _cursor.getColumnIndexOrThrow("datasetName");
    final List<DatasetWithFilledAutofillFields> _result = new ArrayList<DatasetWithFilledAutofillFields>(_cursor.getCount());
    while(_cursor.moveToNext()) {
      final DatasetWithFilledAutofillFields _item_1;
      final AutofillDataset _tmpAutofillDataset;
      if (! (_cursor.isNull(_cursorIndexOfMId) && _cursor.isNull(_cursorIndexOfMDatasetName))) {
        final String _tmpMId;
        _tmpMId = _cursor.getString(_cursorIndexOfMId);
        final String _tmpMDatasetName;
        _tmpMDatasetName = _cursor.getString(_cursorIndexOfMDatasetName);
        _tmpAutofillDataset = new AutofillDataset(_tmpMId,_tmpMDatasetName,null);
      }  else  {
        _tmpAutofillDataset = null;
      }
      _item_1 = new DatasetWithFilledAutofillFields();
      if (!_cursor.isNull(_cursorIndexOfMId)) {
        final String _tmpKey = _cursor.getString(_cursorIndexOfMId);
        ArrayList<FilledAutofillField> _tmpCollection = _collectionFilledAutofillFields.get(_tmpKey);
        if(_tmpCollection == null) {
          _tmpCollection = new ArrayList<FilledAutofillField>();
          _collectionFilledAutofillFields.put(_tmpKey, _tmpCollection);
        }
        _item_1.filledAutofillFields = _tmpCollection;
      }
      _item_1.autofillDataset = _tmpAutofillDataset;
      _result.add(_item_1);
    }
    __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(_collectionFilledAutofillFields);
    return _result;
  } finally {
    _cursor.close();
    _statement.release();
  }
}
 
Example 14
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
@Override
public List<DatasetWithFilledAutofillFields> getDatasetsWithName(List<String> fieldTypes,
    String datasetName) {
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT DISTINCT id, datasetName FROM FilledAutofillField, AutofillDataset WHERE AutofillDataset.id = FilledAutofillField.datasetId AND AutofillDataset.datasetName = (");
  _stringBuilder.append("?");
  _stringBuilder.append(") AND FilledAutofillField.fieldTypeName IN (");
  final int _inputSize = fieldTypes.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 1 + _inputSize;
  final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  if (datasetName == null) {
    _statement.bindNull(_argIndex);
  } else {
    _statement.bindString(_argIndex, datasetName);
  }
  _argIndex = 2;
  for (String _item : fieldTypes) {
    if (_item == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_statement);
  try {
    final ArrayMap<String, ArrayList<FilledAutofillField>> _collectionFilledAutofillFields = new ArrayMap<String, ArrayList<FilledAutofillField>>();
    final int _cursorIndexOfMId = _cursor.getColumnIndexOrThrow("id");
    final int _cursorIndexOfMDatasetName = _cursor.getColumnIndexOrThrow("datasetName");
    final List<DatasetWithFilledAutofillFields> _result = new ArrayList<DatasetWithFilledAutofillFields>(_cursor.getCount());
    while(_cursor.moveToNext()) {
      final DatasetWithFilledAutofillFields _item_1;
      final AutofillDataset _tmpAutofillDataset;
      if (! (_cursor.isNull(_cursorIndexOfMId) && _cursor.isNull(_cursorIndexOfMDatasetName))) {
        final String _tmpMId;
        _tmpMId = _cursor.getString(_cursorIndexOfMId);
        final String _tmpMDatasetName;
        _tmpMDatasetName = _cursor.getString(_cursorIndexOfMDatasetName);
        _tmpAutofillDataset = new AutofillDataset(_tmpMId,_tmpMDatasetName,null);
      }  else  {
        _tmpAutofillDataset = null;
      }
      _item_1 = new DatasetWithFilledAutofillFields();
      if (!_cursor.isNull(_cursorIndexOfMId)) {
        final String _tmpKey = _cursor.getString(_cursorIndexOfMId);
        ArrayList<FilledAutofillField> _tmpCollection = _collectionFilledAutofillFields.get(_tmpKey);
        if(_tmpCollection == null) {
          _tmpCollection = new ArrayList<FilledAutofillField>();
          _collectionFilledAutofillFields.put(_tmpKey, _tmpCollection);
        }
        _item_1.filledAutofillFields = _tmpCollection;
      }
      _item_1.autofillDataset = _tmpAutofillDataset;
      _result.add(_item_1);
    }
    __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(_collectionFilledAutofillFields);
    return _result;
  } finally {
    _cursor.close();
    _statement.release();
  }
}
 
Example 15
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
@Override
public List<FieldTypeWithHeuristics> getFieldTypesForAutofillHints(List<String> autofillHints) {
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, AutofillHint WHERE FieldType.typeName = AutofillHint.fieldTypeName AND AutofillHint.autofillHint IN (");
  final int _inputSize = autofillHints.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(") UNION SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, ResourceIdHeuristic WHERE FieldType.typeName = ResourceIdHeuristic.fieldTypeName");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : autofillHints) {
    if (_item == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_statement);
  try {
    final ArrayMap<String, ArrayList<AutofillHint>> _collectionAutofillHints = new ArrayMap<String, ArrayList<AutofillHint>>();
    final ArrayMap<String, ArrayList<ResourceIdHeuristic>> _collectionResourceIdHeuristics = new ArrayMap<String, ArrayList<ResourceIdHeuristic>>();
    final int _cursorIndexOfMTypeName = _cursor.getColumnIndexOrThrow("typeName");
    final int _cursorIndexOfMAutofillTypes = _cursor.getColumnIndexOrThrow("autofillTypes");
    final int _cursorIndexOfMSaveInfo = _cursor.getColumnIndexOrThrow("saveInfo");
    final int _cursorIndexOfMPartition = _cursor.getColumnIndexOrThrow("partition");
    final int _cursorIndexOfStrictExampleSet = _cursor.getColumnIndexOrThrow("strictExampleSet");
    final int _cursorIndexOfTextTemplate = _cursor.getColumnIndexOrThrow("textTemplate");
    final int _cursorIndexOfDateTemplate = _cursor.getColumnIndexOrThrow("dateTemplate");
    final List<FieldTypeWithHeuristics> _result = new ArrayList<FieldTypeWithHeuristics>(_cursor.getCount());
    while(_cursor.moveToNext()) {
      final FieldTypeWithHeuristics _item_1;
      final FieldType _tmpFieldType;
      if (! (_cursor.isNull(_cursorIndexOfMTypeName) && _cursor.isNull(_cursorIndexOfMAutofillTypes) && _cursor.isNull(_cursorIndexOfMSaveInfo) && _cursor.isNull(_cursorIndexOfMPartition) && _cursor.isNull(_cursorIndexOfStrictExampleSet) && _cursor.isNull(_cursorIndexOfTextTemplate) && _cursor.isNull(_cursorIndexOfDateTemplate))) {
        final String _tmpMTypeName;
        _tmpMTypeName = _cursor.getString(_cursorIndexOfMTypeName);
        final Converters.IntList _tmpMAutofillTypes;
        final String _tmp;
        _tmp = _cursor.getString(_cursorIndexOfMAutofillTypes);
        _tmpMAutofillTypes = Converters.storedStringToIntList(_tmp);
        final Integer _tmpMSaveInfo;
        if (_cursor.isNull(_cursorIndexOfMSaveInfo)) {
          _tmpMSaveInfo = null;
        } else {
          _tmpMSaveInfo = _cursor.getInt(_cursorIndexOfMSaveInfo);
        }
        final Integer _tmpMPartition;
        if (_cursor.isNull(_cursorIndexOfMPartition)) {
          _tmpMPartition = null;
        } else {
          _tmpMPartition = _cursor.getInt(_cursorIndexOfMPartition);
        }
        final FakeData _tmpMFakeData;
        final Converters.StringList _tmpStrictExampleSet;
        final String _tmp_1;
        _tmp_1 = _cursor.getString(_cursorIndexOfStrictExampleSet);
        _tmpStrictExampleSet = Converters.storedStringToStringList(_tmp_1);
        final String _tmpTextTemplate;
        _tmpTextTemplate = _cursor.getString(_cursorIndexOfTextTemplate);
        final String _tmpDateTemplate;
        _tmpDateTemplate = _cursor.getString(_cursorIndexOfDateTemplate);
        _tmpMFakeData = new FakeData(_tmpStrictExampleSet,_tmpTextTemplate,_tmpDateTemplate);
        _tmpFieldType = new FieldType(_tmpMTypeName,_tmpMAutofillTypes,_tmpMSaveInfo,_tmpMPartition,_tmpMFakeData);
      }  else  {
        _tmpFieldType = null;
      }
      _item_1 = new FieldTypeWithHeuristics();
      if (!_cursor.isNull(_cursorIndexOfMTypeName)) {
        final String _tmpKey = _cursor.getString(_cursorIndexOfMTypeName);
        ArrayList<AutofillHint> _tmpCollection = _collectionAutofillHints.get(_tmpKey);
        if(_tmpCollection == null) {
          _tmpCollection = new ArrayList<AutofillHint>();
          _collectionAutofillHints.put(_tmpKey, _tmpCollection);
        }
        _item_1.autofillHints = _tmpCollection;
      }
      if (!_cursor.isNull(_cursorIndexOfMTypeName)) {
        final String _tmpKey_1 = _cursor.getString(_cursorIndexOfMTypeName);
        ArrayList<ResourceIdHeuristic> _tmpCollection_1 = _collectionResourceIdHeuristics.get(_tmpKey_1);
        if(_tmpCollection_1 == null) {
          _tmpCollection_1 = new ArrayList<ResourceIdHeuristic>();
          _collectionResourceIdHeuristics.put(_tmpKey_1, _tmpCollection_1);
        }
        _item_1.resourceIdHeuristics = _tmpCollection_1;
      }
      _item_1.fieldType = _tmpFieldType;
      _result.add(_item_1);
    }
    __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(_collectionAutofillHints);
    __fetchRelationshipResourceIdHeuristicAscomExampleAndroidAutofillServiceModelResourceIdHeuristic(_collectionResourceIdHeuristics);
    return _result;
  } finally {
    _cursor.close();
    _statement.release();
  }
}
 
Example 16
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
private void __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(final ArrayMap<String, ArrayList<FilledAutofillField>> _map) {
  final Set<String> __mapKeySet = _map.keySet();
  if (__mapKeySet.isEmpty()) {
    return;
  }
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT datasetId,textValue,dateValue,toggleValue,fieldTypeName FROM `FilledAutofillField` WHERE datasetId IN (");
  final int _inputSize = __mapKeySet.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : __mapKeySet) {
    if (_item == null) {
      _stmt.bindNull(_argIndex);
    } else {
      _stmt.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_stmt);
  try {
    final int _itemKeyIndex = _cursor.getColumnIndex("datasetId");
    if (_itemKeyIndex == -1) {
      return;
    }
    final int _cursorIndexOfMDatasetId = _cursor.getColumnIndexOrThrow("datasetId");
    final int _cursorIndexOfMTextValue = _cursor.getColumnIndexOrThrow("textValue");
    final int _cursorIndexOfMDateValue = _cursor.getColumnIndexOrThrow("dateValue");
    final int _cursorIndexOfMToggleValue = _cursor.getColumnIndexOrThrow("toggleValue");
    final int _cursorIndexOfMFieldTypeName = _cursor.getColumnIndexOrThrow("fieldTypeName");
    while(_cursor.moveToNext()) {
      if (!_cursor.isNull(_itemKeyIndex)) {
        final String _tmpKey = _cursor.getString(_itemKeyIndex);
        ArrayList<FilledAutofillField> _tmpCollection = _map.get(_tmpKey);
        if (_tmpCollection != null) {
          final FilledAutofillField _item_1;
          final String _tmpMDatasetId;
          _tmpMDatasetId = _cursor.getString(_cursorIndexOfMDatasetId);
          final String _tmpMTextValue;
          _tmpMTextValue = _cursor.getString(_cursorIndexOfMTextValue);
          final Long _tmpMDateValue;
          if (_cursor.isNull(_cursorIndexOfMDateValue)) {
            _tmpMDateValue = null;
          } else {
            _tmpMDateValue = _cursor.getLong(_cursorIndexOfMDateValue);
          }
          final Boolean _tmpMToggleValue;
          final Integer _tmp;
          if (_cursor.isNull(_cursorIndexOfMToggleValue)) {
            _tmp = null;
          } else {
            _tmp = _cursor.getInt(_cursorIndexOfMToggleValue);
          }
          _tmpMToggleValue = _tmp == null ? null : _tmp != 0;
          final String _tmpMFieldTypeName;
          _tmpMFieldTypeName = _cursor.getString(_cursorIndexOfMFieldTypeName);
          _item_1 = new FilledAutofillField(_tmpMDatasetId,_tmpMFieldTypeName,_tmpMTextValue,_tmpMDateValue,_tmpMToggleValue);
          _tmpCollection.add(_item_1);
        }
      }
    }
  } finally {
    _cursor.close();
  }
}
 
Example 17
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
private void __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(final ArrayMap<String, ArrayList<AutofillHint>> _map) {
  final Set<String> __mapKeySet = _map.keySet();
  if (__mapKeySet.isEmpty()) {
    return;
  }
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT autofillHint,fieldTypeName FROM `AutofillHint` WHERE fieldTypeName IN (");
  final int _inputSize = __mapKeySet.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : __mapKeySet) {
    if (_item == null) {
      _stmt.bindNull(_argIndex);
    } else {
      _stmt.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_stmt);
  try {
    final int _itemKeyIndex = _cursor.getColumnIndex("fieldTypeName");
    if (_itemKeyIndex == -1) {
      return;
    }
    final int _cursorIndexOfMAutofillHint = _cursor.getColumnIndexOrThrow("autofillHint");
    final int _cursorIndexOfMFieldTypeName = _cursor.getColumnIndexOrThrow("fieldTypeName");
    while(_cursor.moveToNext()) {
      if (!_cursor.isNull(_itemKeyIndex)) {
        final String _tmpKey = _cursor.getString(_itemKeyIndex);
        ArrayList<AutofillHint> _tmpCollection = _map.get(_tmpKey);
        if (_tmpCollection != null) {
          final AutofillHint _item_1;
          final String _tmpMAutofillHint;
          _tmpMAutofillHint = _cursor.getString(_cursorIndexOfMAutofillHint);
          final String _tmpMFieldTypeName;
          _tmpMFieldTypeName = _cursor.getString(_cursorIndexOfMFieldTypeName);
          _item_1 = new AutofillHint(_tmpMAutofillHint,_tmpMFieldTypeName);
          _tmpCollection.add(_item_1);
        }
      }
    }
  } finally {
    _cursor.close();
  }
}
 
Example 18
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
private void __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(final ArrayMap<String, ArrayList<FilledAutofillField>> _map) {
  final Set<String> __mapKeySet = _map.keySet();
  if (__mapKeySet.isEmpty()) {
    return;
  }
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT datasetId,textValue,dateValue,toggleValue,fieldTypeName FROM `FilledAutofillField` WHERE datasetId IN (");
  final int _inputSize = __mapKeySet.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : __mapKeySet) {
    if (_item == null) {
      _stmt.bindNull(_argIndex);
    } else {
      _stmt.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_stmt);
  try {
    final int _itemKeyIndex = _cursor.getColumnIndex("datasetId");
    if (_itemKeyIndex == -1) {
      return;
    }
    final int _cursorIndexOfMDatasetId = _cursor.getColumnIndexOrThrow("datasetId");
    final int _cursorIndexOfMTextValue = _cursor.getColumnIndexOrThrow("textValue");
    final int _cursorIndexOfMDateValue = _cursor.getColumnIndexOrThrow("dateValue");
    final int _cursorIndexOfMToggleValue = _cursor.getColumnIndexOrThrow("toggleValue");
    final int _cursorIndexOfMFieldTypeName = _cursor.getColumnIndexOrThrow("fieldTypeName");
    while(_cursor.moveToNext()) {
      if (!_cursor.isNull(_itemKeyIndex)) {
        final String _tmpKey = _cursor.getString(_itemKeyIndex);
        ArrayList<FilledAutofillField> _tmpCollection = _map.get(_tmpKey);
        if (_tmpCollection != null) {
          final FilledAutofillField _item_1;
          final String _tmpMDatasetId;
          _tmpMDatasetId = _cursor.getString(_cursorIndexOfMDatasetId);
          final String _tmpMTextValue;
          _tmpMTextValue = _cursor.getString(_cursorIndexOfMTextValue);
          final Long _tmpMDateValue;
          if (_cursor.isNull(_cursorIndexOfMDateValue)) {
            _tmpMDateValue = null;
          } else {
            _tmpMDateValue = _cursor.getLong(_cursorIndexOfMDateValue);
          }
          final Boolean _tmpMToggleValue;
          final Integer _tmp;
          if (_cursor.isNull(_cursorIndexOfMToggleValue)) {
            _tmp = null;
          } else {
            _tmp = _cursor.getInt(_cursorIndexOfMToggleValue);
          }
          _tmpMToggleValue = _tmp == null ? null : _tmp != 0;
          final String _tmpMFieldTypeName;
          _tmpMFieldTypeName = _cursor.getString(_cursorIndexOfMFieldTypeName);
          _item_1 = new FilledAutofillField(_tmpMDatasetId,_tmpMFieldTypeName,_tmpMTextValue,_tmpMDateValue,_tmpMToggleValue);
          _tmpCollection.add(_item_1);
        }
      }
    }
  } finally {
    _cursor.close();
  }
}
 
Example 19
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
@Override
public List<FieldTypeWithHeuristics> getFieldTypesForAutofillHints(List<String> autofillHints) {
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, AutofillHint WHERE FieldType.typeName = AutofillHint.fieldTypeName AND AutofillHint.autofillHint IN (");
  final int _inputSize = autofillHints.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(") UNION SELECT DISTINCT typeName, autofillTypes, saveInfo, partition, strictExampleSet, textTemplate, dateTemplate FROM FieldType, ResourceIdHeuristic WHERE FieldType.typeName = ResourceIdHeuristic.fieldTypeName");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 0 + _inputSize;
  final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  for (String _item : autofillHints) {
    if (_item == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_statement);
  try {
    final ArrayMap<String, ArrayList<AutofillHint>> _collectionAutofillHints = new ArrayMap<String, ArrayList<AutofillHint>>();
    final ArrayMap<String, ArrayList<ResourceIdHeuristic>> _collectionResourceIdHeuristics = new ArrayMap<String, ArrayList<ResourceIdHeuristic>>();
    final int _cursorIndexOfMTypeName = _cursor.getColumnIndexOrThrow("typeName");
    final int _cursorIndexOfMAutofillTypes = _cursor.getColumnIndexOrThrow("autofillTypes");
    final int _cursorIndexOfMSaveInfo = _cursor.getColumnIndexOrThrow("saveInfo");
    final int _cursorIndexOfMPartition = _cursor.getColumnIndexOrThrow("partition");
    final int _cursorIndexOfStrictExampleSet = _cursor.getColumnIndexOrThrow("strictExampleSet");
    final int _cursorIndexOfTextTemplate = _cursor.getColumnIndexOrThrow("textTemplate");
    final int _cursorIndexOfDateTemplate = _cursor.getColumnIndexOrThrow("dateTemplate");
    final List<FieldTypeWithHeuristics> _result = new ArrayList<FieldTypeWithHeuristics>(_cursor.getCount());
    while(_cursor.moveToNext()) {
      final FieldTypeWithHeuristics _item_1;
      final FieldType _tmpFieldType;
      if (! (_cursor.isNull(_cursorIndexOfMTypeName) && _cursor.isNull(_cursorIndexOfMAutofillTypes) && _cursor.isNull(_cursorIndexOfMSaveInfo) && _cursor.isNull(_cursorIndexOfMPartition) && _cursor.isNull(_cursorIndexOfStrictExampleSet) && _cursor.isNull(_cursorIndexOfTextTemplate) && _cursor.isNull(_cursorIndexOfDateTemplate))) {
        final String _tmpMTypeName;
        _tmpMTypeName = _cursor.getString(_cursorIndexOfMTypeName);
        final Converters.IntList _tmpMAutofillTypes;
        final String _tmp;
        _tmp = _cursor.getString(_cursorIndexOfMAutofillTypes);
        _tmpMAutofillTypes = Converters.storedStringToIntList(_tmp);
        final Integer _tmpMSaveInfo;
        if (_cursor.isNull(_cursorIndexOfMSaveInfo)) {
          _tmpMSaveInfo = null;
        } else {
          _tmpMSaveInfo = _cursor.getInt(_cursorIndexOfMSaveInfo);
        }
        final Integer _tmpMPartition;
        if (_cursor.isNull(_cursorIndexOfMPartition)) {
          _tmpMPartition = null;
        } else {
          _tmpMPartition = _cursor.getInt(_cursorIndexOfMPartition);
        }
        final FakeData _tmpMFakeData;
        final Converters.StringList _tmpStrictExampleSet;
        final String _tmp_1;
        _tmp_1 = _cursor.getString(_cursorIndexOfStrictExampleSet);
        _tmpStrictExampleSet = Converters.storedStringToStringList(_tmp_1);
        final String _tmpTextTemplate;
        _tmpTextTemplate = _cursor.getString(_cursorIndexOfTextTemplate);
        final String _tmpDateTemplate;
        _tmpDateTemplate = _cursor.getString(_cursorIndexOfDateTemplate);
        _tmpMFakeData = new FakeData(_tmpStrictExampleSet,_tmpTextTemplate,_tmpDateTemplate);
        _tmpFieldType = new FieldType(_tmpMTypeName,_tmpMAutofillTypes,_tmpMSaveInfo,_tmpMPartition,_tmpMFakeData);
      }  else  {
        _tmpFieldType = null;
      }
      _item_1 = new FieldTypeWithHeuristics();
      if (!_cursor.isNull(_cursorIndexOfMTypeName)) {
        final String _tmpKey = _cursor.getString(_cursorIndexOfMTypeName);
        ArrayList<AutofillHint> _tmpCollection = _collectionAutofillHints.get(_tmpKey);
        if(_tmpCollection == null) {
          _tmpCollection = new ArrayList<AutofillHint>();
          _collectionAutofillHints.put(_tmpKey, _tmpCollection);
        }
        _item_1.autofillHints = _tmpCollection;
      }
      if (!_cursor.isNull(_cursorIndexOfMTypeName)) {
        final String _tmpKey_1 = _cursor.getString(_cursorIndexOfMTypeName);
        ArrayList<ResourceIdHeuristic> _tmpCollection_1 = _collectionResourceIdHeuristics.get(_tmpKey_1);
        if(_tmpCollection_1 == null) {
          _tmpCollection_1 = new ArrayList<ResourceIdHeuristic>();
          _collectionResourceIdHeuristics.put(_tmpKey_1, _tmpCollection_1);
        }
        _item_1.resourceIdHeuristics = _tmpCollection_1;
      }
      _item_1.fieldType = _tmpFieldType;
      _result.add(_item_1);
    }
    __fetchRelationshipAutofillHintAscomExampleAndroidAutofillServiceModelAutofillHint(_collectionAutofillHints);
    __fetchRelationshipResourceIdHeuristicAscomExampleAndroidAutofillServiceModelResourceIdHeuristic(_collectionResourceIdHeuristics);
    return _result;
  } finally {
    _cursor.close();
    _statement.release();
  }
}
 
Example 20
Source File: AutofillDao_Impl.java    From android-AutofillFramework with Apache License 2.0 4 votes vote down vote up
@Override
public List<DatasetWithFilledAutofillFields> getDatasetsWithName(List<String> fieldTypes,
    String datasetName) {
  StringBuilder _stringBuilder = StringUtil.newStringBuilder();
  _stringBuilder.append("SELECT DISTINCT id, datasetName FROM FilledAutofillField, AutofillDataset WHERE AutofillDataset.id = FilledAutofillField.datasetId AND AutofillDataset.datasetName = (");
  _stringBuilder.append("?");
  _stringBuilder.append(") AND FilledAutofillField.fieldTypeName IN (");
  final int _inputSize = fieldTypes.size();
  StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
  _stringBuilder.append(")");
  final String _sql = _stringBuilder.toString();
  final int _argCount = 1 + _inputSize;
  final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount);
  int _argIndex = 1;
  if (datasetName == null) {
    _statement.bindNull(_argIndex);
  } else {
    _statement.bindString(_argIndex, datasetName);
  }
  _argIndex = 2;
  for (String _item : fieldTypes) {
    if (_item == null) {
      _statement.bindNull(_argIndex);
    } else {
      _statement.bindString(_argIndex, _item);
    }
    _argIndex ++;
  }
  final Cursor _cursor = __db.query(_statement);
  try {
    final ArrayMap<String, ArrayList<FilledAutofillField>> _collectionFilledAutofillFields = new ArrayMap<String, ArrayList<FilledAutofillField>>();
    final int _cursorIndexOfMId = _cursor.getColumnIndexOrThrow("id");
    final int _cursorIndexOfMDatasetName = _cursor.getColumnIndexOrThrow("datasetName");
    final List<DatasetWithFilledAutofillFields> _result = new ArrayList<DatasetWithFilledAutofillFields>(_cursor.getCount());
    while(_cursor.moveToNext()) {
      final DatasetWithFilledAutofillFields _item_1;
      final AutofillDataset _tmpAutofillDataset;
      if (! (_cursor.isNull(_cursorIndexOfMId) && _cursor.isNull(_cursorIndexOfMDatasetName))) {
        final String _tmpMId;
        _tmpMId = _cursor.getString(_cursorIndexOfMId);
        final String _tmpMDatasetName;
        _tmpMDatasetName = _cursor.getString(_cursorIndexOfMDatasetName);
        _tmpAutofillDataset = new AutofillDataset(_tmpMId,_tmpMDatasetName,null);
      }  else  {
        _tmpAutofillDataset = null;
      }
      _item_1 = new DatasetWithFilledAutofillFields();
      if (!_cursor.isNull(_cursorIndexOfMId)) {
        final String _tmpKey = _cursor.getString(_cursorIndexOfMId);
        ArrayList<FilledAutofillField> _tmpCollection = _collectionFilledAutofillFields.get(_tmpKey);
        if(_tmpCollection == null) {
          _tmpCollection = new ArrayList<FilledAutofillField>();
          _collectionFilledAutofillFields.put(_tmpKey, _tmpCollection);
        }
        _item_1.filledAutofillFields = _tmpCollection;
      }
      _item_1.autofillDataset = _tmpAutofillDataset;
      _result.add(_item_1);
    }
    __fetchRelationshipFilledAutofillFieldAscomExampleAndroidAutofillServiceModelFilledAutofillField(_collectionFilledAutofillFields);
    return _result;
  } finally {
    _cursor.close();
    _statement.release();
  }
}