java.util.ArrayList#toString ( )源码实例Demo

下面列出了java.util.ArrayList#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jeecg-boot-with-activiti   文件: Test.java
@Override
public String toString() {
    LinkedList<TreeNode> list = new LinkedList<>();
    list.offer(this);
    ArrayList<Integer> res = new ArrayList<>();
    while (!list.isEmpty()) {
        TreeNode node = list.poll();
        res.add(node.val);
        if (node.left != null) {
            list.offer(node.left);
        }
        if (node.right != null) {
            list.offer(node.right);
        }
    }
    return res.toString();
}
 
@GET
@Path("winners2")
@Produces(MediaType.TEXT_PLAIN)
@RolesAllowed("Subscriber")
public String winners2() {
    int remaining = 6;
    ArrayList<Integer> numbers = new ArrayList<>();

    // If the JWT contains a birthdate claim, use the day of the month as a pick
    if (birthdate.isPresent()) {
        String bdayString = birthdate.get().getString();
        LocalDate bday = LocalDate.parse(bdayString);
        numbers.add(bday.getDayOfMonth());
        remaining--;
    }
    // Fill remaining picks with random numbers
    while (remaining > 0) {
        int pick = (int) Math.rint(64 * Math.random() + 1);
        numbers.add(pick);
        remaining--;
    }
    return numbers.toString();
}
 
源代码3 项目: microMathematics   文件: FormulaResult.java
private String fillResultString()
{
    if (resultType == ResultType.NAN)
    {
        return TermParser.CONST_NAN;
    }

    if (resultType == ResultType.CONSTANT)
    {
        constantResult.convertUnit(TermParser.parseUnits(properties.units), /*toBase=*/ true);
        return constantResult.getResultDescription(getFormulaList().getDocumentSettings());
    }

    if (isArrayResult())
    {
        final ArrayList<ArrayList<String>> res = fillResultMatrixArray();
        if (res != null)
        {
            return res.toString();
        }
    }
    return "";
}
 
源代码4 项目: ProRecipes   文件: NBTChecker_v1_10_R1.java
public String getPotionType(String s) {
	//HashMap<String, String> ke = new HashMap<String, String>();
	ArrayList<String> t = new ArrayList<String>();
	byte[] testBytes = Base64Coder.decode(s);
	ByteArrayInputStream buf = new ByteArrayInputStream(testBytes);
   	 try
       {
         NBTTagCompound tag = NBTCompressedStreamTools.a(buf);
         Set<String> keys = tag.c();
         for (String key : keys) {
       	 // System.out.println(key);
       	  String b = tag.get(key).toString();
       	  //System.out.println(b);
       	  String[] arr = b.split(",");
       	  for(int c = 0; c < arr.length; c++){
       		 
       		 //System.out.println("SOMETHING IN A LOOP ?   "  + arr[c]);
       		  if(arr[c].contains("minecraft:")){
       			  return arr[c].replace("minecraft:", "").replace('"', ' ').replace(" ", "");
       		  }
       		  
       	  }
         }
       }
       catch (Exception ex)
       {
       	ex.printStackTrace();
       }
	return t.toString();
}
 
源代码5 项目: ProRecipes   文件: NBTChecker_v1_9_R1.java
public String getPotionType(String s) {
	//HashMap<String, String> ke = new HashMap<String, String>();
	ArrayList<String> t = new ArrayList<String>();
	byte[] testBytes = Base64Coder.decode(s);
	ByteArrayInputStream buf = new ByteArrayInputStream(testBytes);
   	 try
       {
         NBTTagCompound tag = NBTCompressedStreamTools.a(buf);
         Set<String> keys = tag.c();
         for (String key : keys) {
       	 // System.out.println(key);
       	  String b = tag.get(key).toString();
       	  //System.out.println(b);
       	  String[] arr = b.split(",");
       	  for(int c = 0; c < arr.length; c++){
       		 
       		 //System.out.println("SOMETHING IN A LOOP ?   "  + arr[c]);
       		  if(arr[c].contains("minecraft:")){
       			  return arr[c].replace("minecraft:", "").replace('"', ' ').replace(" ", "");
       		  }
       		  
       	  }
         }
       }
       catch (Exception ex)
       {
       	ex.printStackTrace();
       }
	return t.toString();
}
 
源代码6 项目: gemfirexd-oss   文件: JoinNode.java
protected static String[] getTableColumnDetails(ResultSetNode rs)
    throws StandardException {
  final ArrayList<String> tables = new ArrayList<String>();
      
  VisitorAdaptor findLeftTables = new VisitorAdaptor() {
      
    @Override
    public Visitable visit(Visitable node) throws StandardException {
      if (node instanceof FromTable) {
        tables.add("{" + ((FromTable)node).getCorrelationName() + " "
            + ((FromTable)node).getOrigTableName() + "}");
      }
      return node;
    }
  };
      
  rs.accept(findLeftTables);
      
  String involvedTables = tables.toString();
      
  String[] leftRSColumns = rs.resultColumns.getColumnNames();
      
  String[] rsColumnsWithTables = new String[leftRSColumns.length + 1];
  rsColumnsWithTables[0] = involvedTables;
  System.arraycopy(leftRSColumns, 0, rsColumnsWithTables, 1,
      leftRSColumns.length);
      
  return rsColumnsWithTables;
}
 
源代码7 项目: ProRecipes   文件: NBTChecker_v1_12_R1.java
public String getPotionType(String s) {
	//HashMap<String, String> ke = new HashMap<String, String>();
	ArrayList<String> t = new ArrayList<String>();
	byte[] testBytes = Base64Coder.decode(s);
	ByteArrayInputStream buf = new ByteArrayInputStream(testBytes);
   	 try
       {
         NBTTagCompound tag = NBTCompressedStreamTools.a(buf);
         Set<String> keys = tag.c();
         for (String key : keys) {
       	 // System.out.println(key);
       	  String b = tag.get(key).toString();
       	  //System.out.println(b);
       	  String[] arr = b.split(",");
       	  for(int c = 0; c < arr.length; c++){
       		 
       		 //System.out.println("SOMETHING IN A LOOP ?   "  + arr[c]);
       		  if(arr[c].contains("minecraft:")){
       			  return arr[c].replace("minecraft:", "").replace('"', ' ').replace(" ", "");
       		  }
       		  
       	  }
         }
       }
       catch (Exception ex)
       {
       	ex.printStackTrace();
       }
	return t.toString();
}
 
源代码8 项目: jaamsim   文件: KeyedVec3dInput.java
private void parseKey(JaamSimModel simModel, ArrayList<String> key) throws InputErrorException {
	if (key.size() <= 2 || !key.get(0).equals("{") || !key.get(key.size()-1).equals("}")) {
		throw new InputErrorException("Malformed key entry: %s", key.toString());
	}

	ArrayList<ArrayList<String>> keyEntries = InputAgent.splitForNestedBraces(key.subList(1, key.size()-1));
	if (keyEntries.size() != 2) {
		throw new InputErrorException("Expected two values in keyed input for key entry: %s", key.toString());
	}
	ArrayList<String> timeInput = keyEntries.get(0);
	ArrayList<String> valInput = keyEntries.get(1);

	// Validate
	if (timeInput.size() != 4 || !timeInput.get(0).equals("{") || !timeInput.get(timeInput.size()-1).equals("}")) {
		throw new InputErrorException("Time entry not formated correctly: %s", timeInput.toString());
	}
	if (valInput.size() != 6 || !valInput.get(0).equals("{") || !valInput.get(valInput.size()-1).equals("}")) {
		throw new InputErrorException("Value entry not formated correctly: %s", valInput.toString());
	}

	KeywordIndex timeKw = new KeywordIndex("", timeInput, 1, 3, null);
	DoubleVector time = Input.parseDoubles(simModel, timeKw, 0.0d, Double.POSITIVE_INFINITY, TimeUnit.class);

	KeywordIndex valKw = new KeywordIndex("", valInput, 1, 5, null);
	DoubleVector vals = Input.parseDoubles(simModel, valKw, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, unitType);

	Vec3d val = new Vec3d(vals.get(0), vals.get(1), vals.get(2));
	curve.addKey(time.get(0), val);
}
 
源代码9 项目: gemfirexd-oss   文件: JoinNode.java
protected static String[] getTableColumnDetails(ResultSetNode rs)
    throws StandardException {
  final ArrayList<String> tables = new ArrayList<String>();
      
  VisitorAdaptor findLeftTables = new VisitorAdaptor() {
      
    @Override
    public Visitable visit(Visitable node) throws StandardException {
      if (node instanceof FromTable) {
        tables.add("{" + ((FromTable)node).getCorrelationName() + " "
            + ((FromTable)node).getOrigTableName() + "}");
      }
      return node;
    }
  };
      
  rs.accept(findLeftTables);
      
  String involvedTables = tables.toString();
      
  String[] leftRSColumns = rs.resultColumns.getColumnNames();
      
  String[] rsColumnsWithTables = new String[leftRSColumns.length + 1];
  rsColumnsWithTables[0] = involvedTables;
  System.arraycopy(leftRSColumns, 0, rsColumnsWithTables, 1,
      leftRSColumns.length);
      
  return rsColumnsWithTables;
}
 
源代码10 项目: ProRecipes   文件: NBTChecker_v1_8_R3.java
public String getPotionType(String s) {
	ArrayList<String> t = new ArrayList<String>();
	byte[] testBytes = Base64Coder.decode(s);
	ByteArrayInputStream buf = new ByteArrayInputStream(testBytes);
   	 try
       {
         NBTTagCompound tag = NBTCompressedStreamTools.a(buf);
         Set<String> keys = tag.c();
         for (String key : keys) {
       	  String b = tag.get(key).toString();
       	  
       	  String[] arr = b.split(",");
       	  for(int c = 0; c < arr.length; c++){
       		 
       		  //System.out.println("SOMETHING IN A LOOP ?   "  + arr[c]);
       		  if(arr[c].contains("minecraft:")){
       			  return arr[c].replace("minecraft:", "").replace('"', ' ').replace(" ", "");
       		  }
       		  
       	  }
         }
       }
       catch (Exception ex)
       {
       	ex.printStackTrace();
       }
	return t.toString();
}
 
源代码11 项目: dctb-utfpr-2018-1   文件: GerenciadorDeConta.java
public String listarContas() {
    ArrayList<String> list = new ArrayList();
    for (Iterator iterator = contas.iterator(); iterator.hasNext();) {
        Conta c = (Conta) iterator.next();
        list.add(c.toString());
    }
    
    return list.toString();
}
 
源代码12 项目: cuba   文件: AppliedFilter.java
protected String formatParamValue(Param param) {
    Object value = param.getValue();
    if (value == null)
        return "";

    if (param.isDateInterval()) {
        DateIntervalValue dateIntervalValue = AppBeans.getPrototype(DateIntervalValue.NAME, (String) value);
        return dateIntervalValue.getLocalizedValue();
    }

    if (value instanceof Instance)
        return ((Instance) value).getInstanceName();

    if (value instanceof Enum)
        return messages.getMessage((Enum) value);

    if (value instanceof ArrayList){
        ArrayList<String> names = new ArrayList<>();
        ArrayList list = ((ArrayList) value);
        for (Object obj : list) {
            if (obj instanceof Instance)
                names.add(((Instance) obj).getInstanceName());
            else {
                names.add(FilterConditionUtils.formatParamValue(param, obj));
            }
        }
        return names.toString();
    }

    return FilterConditionUtils.formatParamValue(param, value);
}
 
源代码13 项目: openjdk-jdk9   文件: GraalError.java
private static String format(String msg, Object... args) {
    if (args != null) {
        // expand Iterable parameters into a list representation
        for (int i = 0; i < args.length; i++) {
            if (args[i] instanceof Iterable<?>) {
                ArrayList<Object> list = new ArrayList<>();
                for (Object o : (Iterable<?>) args[i]) {
                    list.add(o);
                }
                args[i] = list.toString();
            }
        }
    }
    return String.format(Locale.ENGLISH, msg, args);
}
 
源代码14 项目: openjdk-jdk9   文件: JVMCIError.java
private static String format(String msg, Object... args) {
    if (args != null) {
        // expand Iterable parameters into a list representation
        for (int i = 0; i < args.length; i++) {
            if (args[i] instanceof Iterable<?>) {
                ArrayList<Object> list = new ArrayList<>();
                for (Object o : (Iterable<?>) args[i]) {
                    list.add(o);
                }
                args[i] = list.toString();
            }
        }
    }
    return String.format(Locale.ENGLISH, msg, args);
}
 
源代码15 项目: cqf-ruler   文件: TranslatorHelper.java
public static String errorsToString(Iterable<CqlTranslatorException> exceptions) {
    ArrayList<String> errors = new ArrayList<>();
    for (CqlTranslatorException error : exceptions) {
        TrackBack tb = error.getLocator();
        String lines = tb == null ? "[n/a]" : String.format("%s[%d:%d, %d:%d]",
                (tb.getLibrary() != null ? tb.getLibrary().getId() + (tb.getLibrary().getVersion() != null
                        ? ("-" + tb.getLibrary().getVersion()) : "") : ""),
                tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar());
        errors.add(lines + error.getMessage());
    }

    return errors.toString();
}
 
源代码16 项目: gemfirexd-oss   文件: MBeanTest.java
private static void checkForErrors() {
  ArrayList<String> errorList = (ArrayList<String>) SQLBB.getBB().getSharedMap().get("DATA_ERROR");
  if (errorList != null && errorList.size() > 0) {
    errorList.add(0, "Errors (" + errorList.size() + ") were found:\n");
    throw new TestException(errorList.toString());
  } else {
    Log.getLogWriter().info("*** No Errors Were Found!  Congrats, now go celebrate! ***");
  }
}
 
源代码17 项目: SO   文件: OrchestrationServiceHandler.java
/**
     * OrchestrationService handler.<BR/>
     *
     * @param orchestrationService IGenericOrchestrationService
     */
    public void handle(IGenericOrchestrationService orchestrationService) {

    	String osId, osName, osResult;
    	
        getTracking().setProcess(getClass().getSimpleName());
    
        if (orchestrationService != null) {
        	osId = orchestrationService.getId(); 
        	osName = orchestrationService.getName(); 
        	osResult = "CONTROL_EXECUTION";
        } else {
        	osId = null; 
        	osName = null; 
        	osResult = "CONTROL_IGNORE";
        }

        // grib session
        SessionEntity sessionOs = new SessionEntity();
        sessionOs.setId(getTracking().getSessionId());
        sessionOs.setServicemodelKey(osId);
        sessionOs.setServicemodelName(osName);
        sessionOs.setServicemodelResult(osResult);
        databaseManager.updateSessionData(sessionOs);

        log.trace("session service : {}", sessionOs);

        // OS list : os 를 복수로 확장하게 될 경우 사용
//        if (orchestrationService.getOrchestrationServiceList() != null) {
//            handleOrchestrationServiceList(orchestrationService.getOrchestrationServiceList()
//                    , orchestrationService.getStateStore());
//        }

        // os id 로 Rule body 목록을 조회한다
        log.debug("getRuleBodyListByOsId : {}", osId);
        List<RuleBodyForDB> ruleBodyForDBList = databaseManager.getRuleBodyListByOsId(osId);

        //convert to List<IGenericCompositeVirtualObject>
        List<IGenericCompositeVirtualObject> cvoList = new ArrayList<>();
        for (RuleBodyForDB rubleBodyItem:ruleBodyForDBList) {
        	DefaultCompositeVirtualObject compositeVirtualObject = new DefaultCompositeVirtualObject();
            compositeVirtualObject.setId(rubleBodyItem.getId());

            //cvo_type, physical_device_type_id, device_id
            compositeVirtualObject.setCvoType(rubleBodyItem.getCvoType());
            compositeVirtualObject.setPhysicalDeviceTypeId(rubleBodyItem.getPhysicalDeviceTypeId());
            compositeVirtualObject.setDeviceId(rubleBodyItem.getDeviceId());
        	
            //base_cvo_id, location_id
            compositeVirtualObject.setBaseCvoId(rubleBodyItem.getBaseCvoId());
            compositeVirtualObject.setLocationId(rubleBodyItem.getLocationId());

            compositeVirtualObject.setOsId(rubleBodyItem.getOsId());

        	cvoList.add(compositeVirtualObject);
        }

        
       if (cvoList != null && cvoList.size()>0) {
        	ArrayList<String> cvoIdList= new ArrayList<>();
        	for (int i=0; i< cvoList.size();i++) {
        		IGenericCompositeVirtualObject cvo = cvoList.get(i);
        		//cvoIdList.add(cvo.getId());
        		cvoIdList.add(cvo.getBaseCvoId());
        	}
        	String cvoIds= cvoIdList.toString();
        	String cvoResult = "CONTROL_EXECUTION";
        	
        	sessionOs = new SessionEntity();
            sessionOs.setId(getTracking().getSessionId());
            sessionOs.setServiceKey(cvoIds);
            sessionOs.setServiceResult(cvoResult);
            databaseManager.updateSessionData(sessionOs);

            
        	handleCompositeVirtualObjectList(cvoList, orchestrationService.getStateStore());
        } else {
        	// cvo 목록이 없는 경우에 Happend처리
        	
        	SessionEntity sessionCm = new SessionEntity();
            sessionCm.setId(getTracking().getSessionId());
            sessionCm.setContextmodelResult("Happen"); //Session Data는 완료 처리
            databaseManager.updateSessionData(sessionCm);
        }
    }
 
源代码18 项目: Kylin   文件: CuboidSchedulerTest.java
private String sortToString(Collection<Long> longs) {
    ArrayList<Long> copy = new ArrayList<Long>(longs);
    Collections.sort(copy);
    return copy.toString();
}
 
源代码19 项目: gemfirexd-oss   文件: SQLDistTxTest.java
@SuppressWarnings("unchecked")
/*
 * returns true: when no conflict expected and commit does not gets conflict
 * exception retruns false: when conflict is expected and commit correctly
 * failed with conflict exception
 */
protected boolean verifyBatchingConflictAtCommit(boolean firstCommit,
    SQLException se, boolean getsConflict) {
  // find the keys has been hold by others
  hydra.blackboard.SharedMap modifiedKeysByAllTx = SQLTxBatchingBB.getBB()
      .getSharedMap();

  HashMap<String, Integer> modifiedKeysByThisTx = (HashMap<String, Integer>) SQLDistTxTest.curTxModifiedKeys
      .get();

  Integer myTxId = (Integer) curTxId.get();

  // will be used for mix RC and RR case
  /*
   * SharedMap writeLockedKeysByRRTx = null; Map writeLockedKeysByOtherRR =
   * null;
   * 
   * SharedMap readLockedKeysByRRTx = null; Map readLockedKeysByOtherRR =
   * null;
   */

  boolean expectFKConflict = expectBatchingFKConflict(modifiedKeysByAllTx
      .getMap());

  if (!getsConflict) {
    if (firstCommit && expectFKConflict) {
      throw new TestException(
          "commit with batching "
              + "should get conflict exception but not, need to check log for foreing key constraints");
    }
  }

  // remove those keys are already held by this tx
  for (String key : modifiedKeysByThisTx.keySet()) {
    // log().info("this tx hold the key: " + key);
    ArrayList<Integer> txIdsForTheKey = (ArrayList<Integer>) modifiedKeysByAllTx
        .get(key);
    boolean contains = txIdsForTheKey.remove(myTxId);
    if (!contains)
      throw new TestException(
          "test issue, a key is not added in the batchingBB map");

    if (txIdsForTheKey.size() > 0) {
      if (!getsConflict)
        throw new TestException("commit with batching "
            + "should get conflict exception but not, for key: " + key
            + ", there are following other txId hold the" + " lock locally: "
            + txIdsForTheKey.toString());

      else {
        Log.getLogWriter().info("get expected conflict exception during commit");
        return false;
      }
    }
  }

  // no other txId has the same key could cause conflict
  // txIdsForTheKey.size()==0 for all holding keys
  if (getsConflict) {
    if (expectFKConflict) {
      Log.getLogWriter().info("get expected conflict exception during commit");
      return false;
    } else {
      throw new TestException(
          "does not expect a conflict during commit, but gets "
              + TestHelper.getStackTrace(se));
      // TODO this needs to be revisited depends on how #48195 is being
      // handled by product
      // if the first commit should fail, need to find out a way to
      // check a later op causes the foreign key conflict
      // a possible way is to have every op could cause foreign key conflict
      // writes
      // the conflicting txId to BB, so the conflict could be checked here.
      // (when batching is on)
      // and BB needs to be cleaned after conflict exception is thrown,

    }
  } else {
    if (!expectFKConflict)
      return true;
    else {
      throw new TestException(
          "should get a conflict during commit, but does not. Need to check logs for more info");
    }
  }
}
 
源代码20 项目: IslamicLibraryAndroid   文件: UserDataDBHelper.java
private void deserializeHighlightsAndSave(@NonNull String serializedHighlights, @NonNull PageInfo pageInfo, int bookId) {
    ArrayList<ContentValues> highlights = Highlight.deserializeToContentValues(serializedHighlights,
            pageInfo,
            bookId);
    ArrayList<Integer> existingHighlightsId = new ArrayList<>(highlights.size());

    for (ContentValues highlight_current : highlights) {
        existingHighlightsId
                .add(highlight_current.getAsInteger(UserDataDBContract.HighlightEntry.COLUMN_NAME_HIGHLIGHT_ID));
    }
    String existingHighlightsIdString = existingHighlightsId.toString();

    existingHighlightsIdString = existingHighlightsIdString.replace('[', '(');
    existingHighlightsIdString = existingHighlightsIdString.replace(']', ')');
    SQLiteDatabase db = getWritableDatabase();

    db.beginTransaction();
    try {
        if (highlights.size() != 0) {
            db.delete(UserDataDBContract.HighlightEntry.TABLE_NAME,
                    UserDataDBContract.HighlightEntry.COLUMN_NAME_BOOK_ID + "=?" + " and " +
                            UserDataDBContract.HighlightEntry.COLUMN_NAME_PAGE_ID + "=?" + " and "
                            + UserDataDBContract.HighlightEntry.COLUMN_NAME_HIGHLIGHT_ID + " NOT IN  " +
                            existingHighlightsIdString,
                    new String[]{String.valueOf(bookId), String.valueOf(pageInfo.pageId)}
            );
        } else {
            db.delete(UserDataDBContract.HighlightEntry.TABLE_NAME,
                    UserDataDBContract.HighlightEntry.COLUMN_NAME_BOOK_ID + "=?" + " and " +
                            UserDataDBContract.HighlightEntry.COLUMN_NAME_PAGE_ID + "=?",
                    new String[]{String.valueOf(bookId), String.valueOf(pageInfo.pageId)}
            );
        }

        for (ContentValues highlight : highlights) {
            db.insertWithOnConflict(
                    UserDataDBContract.HighlightEntry.TABLE_NAME,
                    null,
                    highlight,
                    SQLiteDatabase.CONFLICT_IGNORE);
        }
        db.setTransactionSuccessful();
    } catch (SQLException e) {
        Timber.e("deserializeHighlightsAndSave: ", e);
    } finally {
        db.endTransaction();
    }

}