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

The following examples show how to use java.lang.StringBuilder#append() . 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: 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 2
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 3
Source File: ApplicationWithComposite04Impl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void loadDefaultRoutes() {
  StringBuilder sb01 = new StringBuilder();
  this.startRoute = "/mockShell/route04";
  sb01.append("found startRoute >>/mockShell/route04<<");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
  sb01.setLength(0);
  ClientLogger.get().logDetailed(sb01.toString(), 2);
}
 
Example 4
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 5
Source File: GenerateWithIsComponentCreatorImpl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void loadShells() {
  StringBuilder sb01 = new StringBuilder();
  sb01.append("load shell references");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
  super.shellConfiguration.getShells().add(new ShellConfig("/mockShell", "com.github.nalukit.nalu.processor.common.MockShell"));
  sb01.setLength(0);
  sb01.append("register shell >>/mockShell<< with class >>com.github.nalukit.nalu.processor.common.MockShell<<");
  ClientLogger.get().logDetailed(sb01.toString(), 3);
}
 
Example 6
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 7
Source File: ApplicationWithTrackerImpl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void logProcessorVersion() {
  ClientLogger.get().logDetailed("", 0);
  ClientLogger.get().logDetailed("=================================================================================", 0);
  StringBuilder sb01 = new StringBuilder();
  sb01.append("Nalu processor version  >>2.0.1<< used to generate this source");
  ClientLogger.get().logDetailed(sb01.toString(), 0);
  ClientLogger.get().logDetailed("=================================================================================", 0);
  ClientLogger.get().logDetailed("", 0);
}
 
Example 8
Source File: ApplicationWithComposite07Impl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void logProcessorVersion() {
  ClientLogger.get().logDetailed("", 0);
  ClientLogger.get().logDetailed("=================================================================================", 0);
  StringBuilder sb01 = new StringBuilder();
  sb01.append("Nalu processor version  >>2.0.1<< used to generate this source");
  ClientLogger.get().logDetailed(sb01.toString(), 0);
  ClientLogger.get().logDetailed("=================================================================================", 0);
  ClientLogger.get().logDetailed("", 0);
}
 
Example 9
Source File: MyApplicationImpl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void loadDefaultRoutes() {
  StringBuilder sb01 = new StringBuilder();
  this.startRoute = "/mockShell/route01";
  sb01.append("found startRoute >>/mockShell/route01<<");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
  sb01.setLength(0);
  ClientLogger.get().logDetailed(sb01.toString(), 2);
}
 
Example 10
Source File: ApplicationAnnotationOkWithoutLoaderImpl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void loadRoutes() {
  StringBuilder sb01 = new StringBuilder();
  sb01.append("load routes");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
  super.routerConfiguration.getRouters().add(new RouteConfig("/mockShell/route01/*", Arrays.asList(new String[]{"parameter01"}), "selector01", "com.github.nalukit.nalu.processor.common.ui.component01.Controller01"));
  sb01.setLength(0);
  sb01.append("register route >>/mockShell/route01/*<< with parameter >>parameter01<< for selector >>selector01<< for controller >>com.github.nalukit.nalu.processor.common.ui.component01.Controller01<<");
  ClientLogger.get().logDetailed(sb01.toString(), 3);
}
 
Example 11
Source File: ApplicationAnnotationOkWithLoaderImpl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void loadDefaultRoutes() {
  StringBuilder sb01 = new StringBuilder();
  this.startRoute = "/mockShell/route01";
  sb01.append("found startRoute >>/mockShell/route01<<");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
  sb01.setLength(0);
  ClientLogger.get().logDetailed(sb01.toString(), 2);
}
 
Example 12
Source File: ApplicationWithComposite03Impl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void logProcessorVersion() {
  ClientLogger.get().logDetailed("", 0);
  ClientLogger.get().logDetailed("=================================================================================", 0);
  StringBuilder sb01 = new StringBuilder();
  sb01.append("Nalu processor version  >>2.0.1<< used to generate this source");
  ClientLogger.get().logDetailed(sb01.toString(), 0);
  ClientLogger.get().logDetailed("=================================================================================", 0);
  ClientLogger.get().logDetailed("", 0);
}
 
Example 13
Source File: ApplicationAnnotationOkWithoutLoaderImpl.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void loadShells() {
  StringBuilder sb01 = new StringBuilder();
  sb01.append("load shell references");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
  super.shellConfiguration.getShells().add(new ShellConfig("/mockShell", "com.github.nalukit.nalu.processor.common.MockShell"));
  sb01.setLength(0);
  sb01.append("register shell >>/mockShell<< with class >>com.github.nalukit.nalu.processor.common.MockShell<<");
  ClientLogger.get().logDetailed(sb01.toString(), 3);
}
 
Example 14
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 15
Source File: Plog.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private String formatCurve(String name, float[] xs, float[] ys) {
    StringBuilder sb = new StringBuilder();
    sb.append("curve: " + name + ": [");
    int n = xs.length <= ys.length ? xs.length : ys.length;
    for (int i = 0; i < n; i++) {
        sb.append("(" + xs[i] + "," + ys[i] + "),");
    }
    sb.append("]");
    return sb.toString();
}
 
Example 16
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 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: MyApplicationImpl.java    From nalu with Apache License 2.0 4 votes vote down vote up
@Override
public void loadErrorPopUpController() {
  StringBuilder sb01 = new StringBuilder();
  sb01.append("no ErrorPopUpController found!°");
}
 
Example 19
Source File: ApplicationAnnotationOkWithLoaderImpl.java    From nalu with Apache License 2.0 4 votes vote down vote up
@Override
public void loadCompositeReferences() {
  StringBuilder sb01 = new StringBuilder();
  sb01.append("load composite references");
  ClientLogger.get().logDetailed(sb01.toString(), 2);
}
 
Example 20
Source File: ApplicationWithTrackerImpl.java    From nalu with Apache License 2.0 4 votes vote down vote up
@Override
public void loadErrorPopUpController() {
  StringBuilder sb01 = new StringBuilder();
  sb01.append("no ErrorPopUpController found!°");
}