Java Code Examples for java.util.List#size()

The following examples show how to use java.util.List#size() . 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: EsClient.java    From DataLink with Apache License 2.0 6 votes vote down vote up
/**
 *
 * Description: 结构化查询,仅返回结果
 * Created on 2016-6-12 下午5:55:51
 * @author  孔增([email protected])
 * @param vo
 * @return
 */
public static List<String> dslSearchDocument(DSLSearchVo vo) throws UnsupportedEncodingException {
	Long start = System.currentTimeMillis();
	COMMAND_STAT_THREADLOCAL.set(new CollectInfoVo());
	boolean success = false;
	Integer resultNum = 0;
       try {
		List<String> list = DSLSearchDocument.getInstance().dslSearchDocument(vo);
		success = true;
		resultNum = list.size();
		return list;
	}finally {
		long executeTime = System.currentTimeMillis() - start;
		executeLog("dslSearchDocument", vo, vo.getCondition(), executeTime, success, resultNum);
	}
}
 
Example 2
Source File: ClassMemberChecker.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks the classes mentioned in the given class specifications, printing
 * notes if necessary.
 */
public void checkClassSpecifications(List classSpecifications)
{
    if (classSpecifications != null)
    {
        for (int index = 0; index < classSpecifications.size(); index++)
        {
            ClassSpecification classSpecification =
                (ClassSpecification)classSpecifications.get(index);

            String className = classSpecification.className;
            if (className != null             &&
                !containsWildCards(className) &&
                notePrinter.accepts(className))
            {
                Clazz clazz = programClassPool.getClass(className);
                if (clazz != null)
                {
                    checkMemberSpecifications(clazz, classSpecification.fieldSpecifications,  true);
                    checkMemberSpecifications(clazz, classSpecification.methodSpecifications, false);
                }
            }
        }
    }
}
 
Example 3
Source File: EarProjectProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Acquires modules (in the form of projects) from "JAVA EE Modules" not from the deployment descriptor (application.xml).
 * <p>
 * The reason is that for JAVA EE 5 the deployment descriptor is not compulsory.
 * @param moduleType the type of module, see {@link J2eeModule.Type J2eeModule constants}.
 *                   If it is <code>null</code> then all modules are returned.
 * @return list of EAR project subprojects.
 */
static List<Project> getApplicationSubprojects(List<ClassPathSupport.Item> items, J2eeModule.Type moduleType) {
    List<Project> projects = new ArrayList<Project>(items.size());
    for (ClassPathSupport.Item item : items) {
        if (item.getType() != ClassPathSupport.Item.TYPE_ARTIFACT || item.getArtifact() == null) {
            continue;
        }
        Project vcpiProject = item.getArtifact().getProject();
        J2eeModuleProvider jmp = vcpiProject.getLookup().lookup(J2eeModuleProvider.class);
        if (jmp == null) {
            continue;
        }
        if (moduleType == null) {
            projects.add(vcpiProject);
        } else if (moduleType.equals(jmp.getJ2eeModule().getType())) {
            projects.add(vcpiProject);
        }
    }
    return projects;
}
 
Example 4
Source File: NavigationPropertyCustom.java    From FROST-Server with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void findLinkTargetData(Entity<?> entity, EntityProperty entityProperty, List<String> subPath, String name, EntityType type) {
    clear();
    Object curTarget = entityProperty.getFrom(entity);
    int count = subPath.size() - 1;
    for (int idx = 0; idx < count; idx++) {
        String curPathItem = subPath.get(idx);
        if (curTarget instanceof Map) {
            Map<String, Object> map = (Map<String, Object>) curTarget;
            curTarget = map.get(curPathItem);
        } else {
            return;
        }
    }
    if (curTarget instanceof Map) {
        findLinkEntryInMap((Map<String, Object>) curTarget, name, type);
    }
    this.entity = entity;
}
 
Example 5
Source File: AdsMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private void onAdSourceInfoRefreshed(MediaSource mediaSource, int adGroupIndex,
    int adIndexInAdGroup, Timeline timeline) {
  Assertions.checkArgument(timeline.getPeriodCount() == 1);
  adGroupTimelines[adGroupIndex][adIndexInAdGroup] = timeline;
  List<MaskingMediaPeriod> mediaPeriods = maskingMediaPeriodByAdMediaSource.remove(mediaSource);
  if (mediaPeriods != null) {
    Object periodUid = timeline.getUidOfPeriod(/* periodIndex= */ 0);
    for (int i = 0; i < mediaPeriods.size(); i++) {
      MaskingMediaPeriod mediaPeriod = mediaPeriods.get(i);
      MediaPeriodId adSourceMediaPeriodId =
          new MediaPeriodId(periodUid, mediaPeriod.id.windowSequenceNumber);
      mediaPeriod.createPeriod(adSourceMediaPeriodId);
    }
  }
  maybeUpdateSourceInfo();
}
 
Example 6
Source File: JwkUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<JsonWebKey> stripPrivateParameters(List<JsonWebKey> keys) {
    if (keys == null) {
        return Collections.emptyList();
    }

    List<JsonWebKey> parsedKeys = new ArrayList<>(keys.size());
    Iterator<JsonWebKey> iter = keys.iterator();
    while (iter.hasNext()) {
        JsonWebKey key = iter.next();
        if (!(key.containsProperty("k") || key.getKeyType() == KeyType.OCTET)) {
            // We don't allow secret keys in a public keyset
            key.removeProperty(JsonWebKey.RSA_PRIVATE_EXP);
            key.removeProperty(JsonWebKey.RSA_FIRST_PRIME_FACTOR);
            key.removeProperty(JsonWebKey.RSA_SECOND_PRIME_FACTOR);
            key.removeProperty(JsonWebKey.RSA_FIRST_PRIME_CRT);
            key.removeProperty(JsonWebKey.RSA_SECOND_PRIME_CRT);
            key.removeProperty(JsonWebKey.RSA_FIRST_CRT_COEFFICIENT);
            parsedKeys.add(key);
        }
    }
    return parsedKeys;
}
 
Example 7
Source File: AutoRunatoriumInstance.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onEnterInstance(Player player) {
	super.onEnterInstance(player);
	List<Player> playersByRace = getPlayersByRace(player.getRace());
	playersByRace.remove(player);
	if (playersByRace.size() == 1 && !playersByRace.get(0).isInGroup2()) {
		PlayerGroup newGroup = PlayerGroupService.createGroup(playersByRace.get(0), player, TeamType.AUTO_GROUP);
		int groupId = newGroup.getObjectId();
		if (!instance.isRegistered(groupId)) {
			instance.register(groupId);
		}
	}
	else if (!playersByRace.isEmpty() && playersByRace.get(0).isInGroup2()) {
		PlayerGroupService.addPlayer(playersByRace.get(0).getPlayerGroup2(), player);
	}
	Integer object = player.getObjectId();
	if (!instance.isRegistered(object)) {
		instance.register(object);
	}
}
 
Example 8
Source File: InternetDomainName.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Validation method used by {@from} to ensure that the domain name is syntactically valid
 * according to RFC 1035.
 *
 * @return Is the domain name syntactically valid?
 */

private static boolean validateSyntax(List<String> parts) {
  final int lastIndex = parts.size() - 1;

  // Validate the last part specially, as it has different syntax rules.
  if (!validatePart(parts.get(lastIndex), true)) {
    return false;
  }
  for (int i = 0; i < lastIndex; i++) {
    String part = parts.get(i);
    if (!validatePart(part, false)) {
      return false;
    }
  }
  return true;
}
 
Example 9
Source File: OCUtils.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
public static List<File> createRandomAboxAxiomPartitionsAsFiles(OWLOntology ont, int numberOfPartitions, long seed)
		throws OWLOntologyCreationException, IOException {
	List<OWLOntology> onts = createRandomAboxAxiomPartitions(ont, numberOfPartitions, seed);
	List<File> ret = new ArrayList<File>(onts.size());
	for (OWLOntology o: onts) {
		File tempFile = File.createTempFile("ont", ".rdf");
		saveRDFXML(o, tempFile);
		ret.add(tempFile);
		logger.debug("abox temp file: {}",tempFile.getAbsolutePath());
	}
	
	return ret;
}
 
Example 10
Source File: IIOMetadataFormatImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Object[] getObjectEnumerations(String elementName) {
    ObjectValue objv = getObjectValue(elementName);
    if (objv.valueType != VALUE_ENUMERATION) {
        throw new IllegalArgumentException("Not an enumeration!");
    }
    List vlist = objv.enumeratedValues;
    Object[] values = new Object[vlist.size()];
    return vlist.toArray(values);
}
 
Example 11
Source File: DoorsNLocksSubsystem.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private List<LockAuthorizationOperation> operationsFromMaps(List<Map<String,Object>> operations) {
   if(operations == null) {
      return new ArrayList<>();
   }
   List<LockAuthorizationOperation> ops = new ArrayList<>(operations.size());
   for(Map<String,Object> op : operations) {
      ops.add(new LockAuthorizationOperation(op));
   }
   return ops;
}
 
Example 12
Source File: CopyCellContentsContextAction.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public boolean canCopy( List selection )
{
	if ( selection.size( ) == 1
			&& selection.get( 0 ) instanceof TableCellEditPart )
	{
		TableCellEditPart tcep = (TableCellEditPart) selection.get( 0 );
		CellHandle cellHandle = (CellHandle) tcep.getModel( );
		return cellHandle.getContent( ).getCount( ) > 0;
	}
	return false;
}
 
Example 13
Source File: UEAdapter.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
public boolean addItems(List<?> datas){
	if (datas.size() < 0) {
		return true;
	}
	if (className != null) {
		if (className != datas.get(0).getClass()) {
			return false;
		}
	}else {
		className = datas.get(0).getClass();
	}
	this.datas.addAll(changeObject(datas));
	notifyDataSetChanged();
	return true;
}
 
Example 14
Source File: ShardMetadataRecordCursor.java    From presto with Apache License 2.0 5 votes vote down vote up
private static int getColumnIndex(ConnectorTableMetadata tableMetadata, String columnName)
{
    List<ColumnMetadata> columns = tableMetadata.getColumns();
    for (int i = 0; i < columns.size(); i++) {
        if (columns.get(i).getName().equals(columnName)) {
            return i;
        }
    }
    throw new IllegalArgumentException(format("Column '%s' not found", columnName));
}
 
Example 15
Source File: SubjectFragment.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
@Override
public void showBookList(List<BookLists.BookListsBean> bookLists, boolean isRefresh) {
    if (isRefresh) {
        mAdapter.clear();
        start = 0;
    }
    mAdapter.addAll(bookLists);
    start = start + bookLists.size();
}
 
Example 16
Source File: CHECKSHAPE.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
static Boolean recValidateShape(List list, List<Long> candidateShape) {
  List<Long> copyShape =  new ArrayList<Long>(candidateShape);

  if (list.size() != copyShape.remove(0)) {
    return false;
  }

  if (!hasNestedList(list)) {
    return 0 == copyShape.size();

  } else if (0 == copyShape.size()) {
    return false;

  } else {

    for (Object el: list) {
      if (!(el instanceof List)) {
        return false;
      }

      if (!recValidateShape((List) el, copyShape)) {
        return false;
      }
    }

    return true;
  }
}
 
Example 17
Source File: L3.java    From spork with Apache License 2.0 5 votes vote down vote up
public void reduce(
        Text key,
        Iterator<Text> iter, 
        OutputCollector<Text, Text> oc,
        Reporter reporter) throws IOException {
    // For each value, figure out which file it's from and store it
    // accordingly.
    List<String> first = new ArrayList<String>();
    List<String> second = new ArrayList<String>();

    while (iter.hasNext()) {
        Text t = iter.next();
        String value = t.toString();
        if (value.charAt(0) == '1') first.add(value.substring(1));
        else second.add(value.substring(1));
        reporter.setStatus("OK");
    }

    reporter.setStatus("OK");

    if (first.size() == 0 || second.size() == 0) return;

    // Do the cross product, and calculate the sum
    Double sum = 0.0;
    for (String s1 : first) {
        for (String s2 : second) {
            try {
                sum += Double.valueOf(s1);
            } catch (NumberFormatException nfe) {
            }
        }
    }
    oc.collect(null, new Text(key.toString() + "" +  sum.toString()));
}
 
Example 18
Source File: MCSFunctions.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public StereoMolecule getMaximumCommonSubstructure(List<StereoMolecule> li) throws Exception {
	
	StereoMolecule molMCS = li.get(0);
	
	List<StereoMolecule> liMCS = new ArrayList<StereoMolecule>();
	
	liMCS.add(molMCS);
			
	for (int i = 1; i < li.size(); i++) {
		
		StereoMolecule mol = li.get(i);
		
		mcs.set(mol, molMCS);
		
		molMCS = mcs.getMCS();
		
		if(molMCS==null){
			System.err.println("No common substructure found. break!");
		}
	}
			
	return molMCS;
	
}
 
Example 19
Source File: ShuffleStream.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public ShuffleStream(StreamExpression expression, StreamFactory factory) throws IOException {
  // grab all parameters out
  String collectionName = factory.getValueOperand(expression, 0);
  List<StreamExpressionNamedParameter> namedParams = factory.getNamedOperands(expression);
  StreamExpressionNamedParameter aliasExpression = factory.getNamedOperand(expression, "aliases");
  StreamExpressionNamedParameter zkHostExpression = factory.getNamedOperand(expression, "zkHost");

  // Collection Name
  if(null == collectionName){
    throw new IOException(String.format(Locale.ROOT,"invalid expression %s - collectionName expected as first operand",expression));
  }

  // Validate there are no unknown parameters - zkHost and alias are namedParameter so we don't need to count it twice
  if(expression.getParameters().size() != 1 + namedParams.size()){
    throw new IOException(String.format(Locale.ROOT,"invalid expression %s - unknown operands found",expression));
  }

  // Named parameters - passed directly to solr as solrparams
  if(0 == namedParams.size()){
    throw new IOException(String.format(Locale.ROOT,"invalid expression %s - at least one named parameter expected. eg. 'q=*:*'",expression));
  }

  ModifiableSolrParams mParams = new ModifiableSolrParams();
  for(StreamExpressionNamedParameter namedParam : namedParams){
    if(!namedParam.getName().equals("zkHost") && !namedParam.getName().equals("aliases")){
      mParams.add(namedParam.getName(), namedParam.getParameter().toString().trim());
    }
  }

  // Aliases, optional, if provided then need to split
  if(null != aliasExpression && aliasExpression.getParameter() instanceof StreamExpressionValue){
    fieldMappings = new HashMap<>();
    for(String mapping : ((StreamExpressionValue)aliasExpression.getParameter()).getValue().split(",")){
      String[] parts = mapping.trim().split("=");
      if(2 == parts.length){
        fieldMappings.put(parts[0], parts[1]);
      }
      else{
        throw new IOException(String.format(Locale.ROOT,"invalid expression %s - alias expected of the format origName=newName",expression));
      }
    }
  }

  // zkHost, optional - if not provided then will look into factory list to get
  String zkHost = null;
  if(null == zkHostExpression){
    zkHost = factory.getCollectionZkHost(collectionName);
    if(zkHost == null) {
      zkHost = factory.getDefaultZkHost();
    }
  }
  else if(zkHostExpression.getParameter() instanceof StreamExpressionValue){
    zkHost = ((StreamExpressionValue)zkHostExpression.getParameter()).getValue();
  }
  if(null == zkHost){
    throw new IOException(String.format(Locale.ROOT,"invalid expression %s - zkHost not found for collection '%s'",expression,collectionName));
  }

  // We've got all the required items
  init(collectionName, zkHost, mParams);
}
 
Example 20
Source File: SpellingDialog.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Navigate to the next misspelt word, or break out if complete.
 */
private void nextWord() {
    if(wordsToCorrect.isEmpty()) {
        dialogStage.hide();
        area.updateSpelling(true);
        Button ok = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"));
        VBox.setMargin(ok, new Insets(10));
        final Stage doneSpellingStage = new Stage();
        doneSpellingStage.setTitle(LabelGrabber.INSTANCE.getLabel("complete.title"));
        ok.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                doneSpellingStage.hide();
            }
        });
        doneSpellingStage.initModality(Modality.WINDOW_MODAL);
        VBox spellingBox = new VBox();
        spellingBox.getChildren().add(new Label(LabelGrabber.INSTANCE.getLabel("spelling.complete.text")));
        spellingBox.getChildren().add(ok);
        spellingBox.setAlignment(Pos.CENTER);
        spellingBox.setPadding(new Insets(15));
        Scene scene = new Scene(spellingBox);
        if (QueleaProperties.get().getUseDarkTheme()) {
            scene.getStylesheets().add("org/modena_dark.css");
        }
        doneSpellingStage.setScene(scene);
        doneSpellingStage.show();
        return;
    }
    List<String> origPieces = Arrays.asList(Pattern.compile(Speller.SPELLING_REGEX, Pattern.UNICODE_CHARACTER_CLASS).split(origText));
    String replaceWord = wordsToCorrect.iterator().next();
    int index = origPieces.indexOf(replaceWord);
    int lower = index - 6;
    if(lower < 0) {
        lower = 0;
    }
    int upper = index + 6;
    if(upper > origPieces.size() - 1) {
        upper = origPieces.size() - 1;
    }
    textPane.getChildren().clear();
    textPane.getChildren().add(new Label("..."));
    for(String str : origPieces.subList(lower, upper + 1)) {
        Text text = new Text(str + " ");
        text.getStyleClass().add("text");
        if(str.equals(replaceWord)) {
            text.setFill(Color.RED);
        }
        textPane.getChildren().add(text);
    }
    textPane.getChildren().add(new Label("..."));
    suggestions.getItems().clear();
    for(String suggestion : speller.getSuggestions(replaceWord)) {
        suggestions.getItems().add(suggestion);
    }
}