java.util.SortedMap#get ( )源码实例Demo

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

@Override
protected boolean matchesSafely(
    ConvertConfigurationAnswerElement item, Description mismatchDescription) {
  SortedMap<String, SortedMap<String, SortedMap<String, DefinedStructureInfo>>> byFile =
      item.getDefinedStructures();
  if (!byFile.containsKey(_filename)) {
    mismatchDescription.appendText(
        String.format("File '%s' has no defined structures", _filename));
    return false;
  }
  SortedMap<String, SortedMap<String, DefinedStructureInfo>> byType = byFile.get(_filename);
  if (!byType.containsKey(_type)) {
    mismatchDescription.appendText(
        String.format("File '%s' has no defined structure of type '%s'", _filename, _type));
    return false;
  }
  SortedMap<String, DefinedStructureInfo> byStructureName = byType.get(_type);
  if (!byStructureName.containsKey(_structureName)) {
    mismatchDescription.appendText(
        String.format(
            "File '%s' has no defined structure of type '%s' named '%s'",
            _filename, _type, _structureName));
    return false;
  }
  return true;
}
 
源代码2 项目: kafka-assigner   文件: KafkaAssignmentStrategy.java
private static void assignOrphans(
        String topicName, SortedMap<Integer, Node> nodeMap,
        Map<Integer, Integer> orphanedReplicas) {
    // Don't process nodes in the same order for all topics to ensure that topics with fewer
    // replicas than nodes are equally likely to be assigned anywhere (and not overload the
    // brokers with earlier IDs).
    Integer[] nodeProcessingOrder = getNodeProcessingOrder(topicName, nodeMap.keySet());
    List<Integer> nodeProcessingOrderList = Arrays.asList(nodeProcessingOrder);

    // Assign unassigned replicas to nodes that can accept them
    for (Map.Entry<Integer, Integer> e : orphanedReplicas.entrySet()) {
        int partition = e.getKey();
        int remainingReplicas = e.getValue();
        Iterator<Integer> nodeIt = nodeProcessingOrderList.iterator();
        while (nodeIt.hasNext() && remainingReplicas > 0) {
            Node node = nodeMap.get(nodeIt.next());
            if (node.canAccept(partition)) {
                node.accept(partition);
                remainingReplicas--;
            }
        }
        Preconditions.checkState(remainingReplicas == 0, "Partition " + partition +
                " could not be fully assigned!");
    }
}
 
@Test
public void testOneInRange() {
    // 12 AM - 1 AM
    long start_time_ms = new DateTime(2000, 1, 1, 0, 0, 0, 0, DTZ).getMillis();
    long start_time_s = TimeUnit.MILLISECONDS.toSeconds(start_time_ms);
    long end_time_ms = start_time_ms + TimeUnit.HOURS.toMillis(1);
    long end_time_s = TimeUnit.MILLISECONDS.toSeconds(end_time_ms);
    AgendaItem item = new AgendaItem();
    item.setEpochStartTime(start_time_s);
    item.setEpochEndTime(end_time_s);

    long look_ahead = TimeUnit.DAYS.toMillis(1);
    long now = start_time_ms - look_ahead + 1;  // Just inside of range
    final List<AgendaItem> items_in = Collections.singletonList(item);
    final SortedMap<DateRange, List<AgendaItem>> map =
        AgendaItems.upNext(items_in, now, TimeUnit.DAYS.toMillis(1), 0);

    assertEquals(1, map.size());
    final DateRange dr = map.firstKey();
    assertNotNull(dr);
    assertEquals(start_time_ms, dr.start);
    assertEquals(end_time_ms, dr.end);
    final List<AgendaItem> items_out = map.get(dr);
    assertEquals(1, items_out.size());
    assertSame(item, items_out.get(0));
}
 
源代码4 项目: dragonwell8_jdk   文件: MalformedSurrogates.java
public static void main(String[] args) throws IOException {
    SortedMap<String, Charset> map = Charset.availableCharsets();
    for (String name : map.keySet()) {
        Charset charset = map.get(name);
        if (charset.canEncode() && !charset.name().equals("x-COMPOUND_TEXT")) {
            testNormalSurrogate(charset, NORMAL_SURROGATE);
            testMalformedSurrogate(charset, MALFORMED_SURROGATE);
            testMalformedSurrogate(charset, REVERSED_SURROGATE);
            testMalformedSurrogate(charset, SOLITARY_HIGH_SURROGATE);
            testMalformedSurrogate(charset, SOLITARY_LOW_SURROGATE);
            testSurrogateWithReplacement(charset, NORMAL_SURROGATE);
            testSurrogateWithReplacement(charset, MALFORMED_SURROGATE);
            testSurrogateWithReplacement(charset, REVERSED_SURROGATE);
            testSurrogateWithReplacement(charset, SOLITARY_HIGH_SURROGATE);
            testSurrogateWithReplacement(charset, SOLITARY_LOW_SURROGATE);
        }
    }
}
 
源代码5 项目: xxl-job   文件: ExecutorRouteConsistentHash.java
public String hashJob(int jobId, List<String> addressList) {

        // ------A1------A2-------A3------
        // -----------J1------------------
        TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
        for (String address: addressList) {
            for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
                long addressHash = hash("SHARD-" + address + "-NODE-" + i);
                addressRing.put(addressHash, address);
            }
        }

        long jobHash = hash(String.valueOf(jobId));
        SortedMap<Long, String> lastRing = addressRing.tailMap(jobHash);
        if (!lastRing.isEmpty()) {
            return lastRing.get(lastRing.firstKey());
        }
        return addressRing.firstEntry().getValue();
    }
 
@Override
protected boolean matchesSafely(
    ConvertConfigurationAnswerElement item, Description mismatchDescription) {
  SortedMap<String, SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>>>
      byFile = item.getUndefinedReferences();
  if (!byFile.containsKey(_filename)) {
    mismatchDescription.appendText(
        String.format("File '%s' has no undefined references", _filename));
    return false;
  }
  SortedMap<String, SortedMap<String, SortedMap<String, SortedSet<Integer>>>> byType =
      byFile.get(_filename);
  if (!byType.containsKey(_type)) {
    mismatchDescription.appendText(
        String.format(
            "File '%s' has no undefined references to structures of type '%s'",
            _filename, _type));
    return false;
  }
  SortedMap<String, SortedMap<String, SortedSet<Integer>>> byStructureName = byType.get(_type);
  if (!byStructureName.containsKey(_structureName)) {
    mismatchDescription.appendText(
        String.format(
            "File '%s' has no undefined references to structures of type '%s' named '%s'",
            _filename, _type, _structureName));
    return false;
  }
  SortedMap<String, SortedSet<Integer>> byUsage = byStructureName.get(_structureName);
  if (!byUsage.containsKey(_usage)) {
    mismatchDescription.appendText(
        String.format(
            "File '%s' has no undefined references to structures of type '%s' named '%s' of "
                + "usage '%s'",
            _filename, _type, _structureName, _usage));
    return false;
  }
  return true;
}
 
@Test
public void validateCreatingDependencyInformationMapFromDependencyPropertiesFile() {

    // Assemble
    final String jaxbApiKey = "javax.xml.bind/jaxb-api";
    final URL depsPropResource = getClass().getResource(DEPS1_PROPERTYFILE);

    // Act
    final SortedMap<String, String> versionMap = DependsFileParser.getVersionMap(depsPropResource);
    final SortedMap<String, DependencyInfo> diMap = DependsFileParser.createDependencyInfoMap(versionMap);

    // Assert
    final DependencyInfo dependencyInfo = diMap.get(jaxbApiKey);
    Assert.assertNotNull(dependencyInfo);

    Assert.assertEquals("javax.xml.bind", dependencyInfo.getGroupId());
    Assert.assertEquals("jaxb-api", dependencyInfo.getArtifactId());
    Assert.assertEquals("2.2.11", dependencyInfo.getVersion());
    Assert.assertEquals("jar", dependencyInfo.getType());
    Assert.assertEquals("compile", dependencyInfo.getScope());

    /*
    for(Map.Entry<String, DependencyInfo> current : diMap.entrySet()) {
        System.out.println(" [" + current.getKey() + "]: " + current.getValue());
    }
    */
}
 
源代码8 项目: RDFS   文件: SimpleSeekableFormatInputStream.java
/**
 * This function seeks forward using all "available" bytes.
 * It returns the offset after the seek.
 *
 * This function throws EOFException if there are no available complete metaDataBlock
 * or the metaDataBlock points to a position after the file end (e.g. truncated files).
 */
public long seekForward() throws IOException {
  // Try to read the last metadata block
  interleavedIn.skipToLastAvailableMetaDataBlock();
  if (!interleavedIn.readMetaDataIfNeeded()) {
    throw new EOFException("Cannot get a complete metadata block");
  }

  // Move the interleavedIn to the beginning of a dataSegment
  SortedMap<Long, Long> offsetPairs = metaData.getOffsetPairs();
  // The last key in the offsetPair points to the farthest position that we can seek to.
  long uncompressedDataOffset = offsetPairs.lastKey();
  long compressedDataOffset = offsetPairs.get(uncompressedDataOffset);
  long toSkip = compressedDataOffset - interleavedIn.getDataOffset();
  if (toSkip < 0) {
    throw new CorruptedDataException("SSF format error: The last offset pair is before the current position in InterleaveStream!");
  }
  try {
    interleavedIn.skipExactly(toSkip);
  } catch (EOFException e) {
    // Ignore this exception
    // This is the PTail use case.  We don't care about this CodecPrematureEOFException
  }

  clearDataSegment();
  return uncompressedDataOffset;
}
 
源代码9 项目: pulsar   文件: InMemTransactionBufferReaderTest.java
private void verifyEntriesReleased(SortedMap<Long, ByteBuf> entries,
                                   long startSequenceId,
                                   int numEntriesToRead) {
    for (int i = 0; i < numEntriesToRead; i++) {
        long sequenceId = startSequenceId + i;
        ByteBuf bb = entries.get(sequenceId);
        assertNotNull(bb);
        assertEquals(bb.refCnt(), 0);
    }
}
 
源代码10 项目: chassis   文件: MetricsCloudWatchReporter.java
private void addCounters(SortedMap<String, Counter> counters, LinkedList<PutMetricDataRequest> requests, Date timestamp) {
    logger.debug("Adding Counters...");
    for (String name : counters.keySet()) {
        Counter counter = counters.get(name);
        addDatum(filter.getMatchingMetricDescriptor(name, Stat.ALL).getAlias(), counter.getCount(), requests, timestamp);
    }
}
 
源代码11 项目: RDFS   文件: DataJoinReducerBase.java
/**
 * This is the function that re-groups values for a key into sub-groups based
 * on a secondary key (input tag).
 * 
 * @param arg1
 * @return
 */
private SortedMap<Object, ResetableIterator> regroup(Object key,
                                                     Iterator arg1, Reporter reporter) throws IOException {
  this.numOfValues = 0;
  SortedMap<Object, ResetableIterator> retv = new TreeMap<Object, ResetableIterator>();
  TaggedMapOutput aRecord = null;
  while (arg1.hasNext()) {
    this.numOfValues += 1;
    if (this.numOfValues % 100 == 0) {
      reporter.setStatus("key: " + key.toString() + " numOfValues: "
                         + this.numOfValues);
    }
    if (this.numOfValues > this.maxNumOfValuesPerGroup) {
      continue;
    }
    aRecord = ((TaggedMapOutput) arg1.next()).clone(job);
    Text tag = aRecord.getTag();
    ResetableIterator data = retv.get(tag);
    if (data == null) {
      data = createResetableIterator();
      retv.put(tag, data);
    }
    data.add(aRecord);
  }
  if (this.numOfValues > this.largestNumOfValues) {
    this.largestNumOfValues = numOfValues;
    LOG.info("key: " + key.toString() + " this.largestNumOfValues: "
             + this.largestNumOfValues);
  }
  return retv;
}
 
@Test
public void testAtStartOfTwoSameRange() {
    // 12 AM - 1 AM
    long start_time_ms = new DateTime(2000, 1, 1, 0, 0, 0, 0, DTZ).getMillis();
    long start_time_s = TimeUnit.MILLISECONDS.toSeconds(start_time_ms);
    long end_time_ms = start_time_ms + TimeUnit.HOURS.toMillis(1);
    long end_time_s = TimeUnit.MILLISECONDS.toSeconds(end_time_ms);
    AgendaItem item0 = new AgendaItem();
    item0.setEpochStartTime(start_time_s);
    item0.setEpochEndTime(end_time_s);
    AgendaItem item1 = new AgendaItem();
    item1.setEpochStartTime(start_time_s);
    item1.setEpochEndTime(end_time_s);

    final List<AgendaItem> items_in = Arrays.asList(item0, item1);
    final SortedMap<DateRange, List<AgendaItem>> map =
        AgendaItems.happeningNow(items_in, start_time_ms);

    assertEquals(1, map.size());
    final DateRange dr = map.firstKey();
    assertNotNull(dr);
    assertEquals(start_time_ms, dr.start);
    assertEquals(end_time_ms, dr.end);
    final List<AgendaItem> items_out = map.get(dr);
    assertEquals(2, items_out.size());
    assertSame(item0, items_out.get(0));
    assertSame(item1, items_out.get(1));
}
 
private void addToMap(BigInteger N, int exp, SortedMap<BigInteger, Integer> map) {
	Integer oldExp = map.get(N);
	// old entry is replaced if oldExp!=null
	map.put(N, (oldExp == null) ? exp : oldExp+exp);
}
 
源代码14 项目: jasperreports   文件: JRXlsAbstractExporter.java
protected void mergeAndSetRowLevels(XlsRowLevelInfo levelInfo, SortedMap<String, Boolean> rowLevelMap, int rowIndex)
	{
		if (rowLevelMap != null)
		{
			SortedMap<String, Integer> crtLevelMap = levelInfo.getLevelMap();

			for (String level : rowLevelMap.keySet())
			{
				Boolean isEndMarker = rowLevelMap.get(level);
				
				//check if this level group is already open
				if (crtLevelMap.containsKey(level))
				{
					//the level group is already open
					
					if (isEndMarker)
					{
						//the level group needs to be closed, together with all its child level groups
						setRowLevels(levelInfo, level);

						//clean up current level group and nested level groups as they were closed 
						for (Iterator<String> it = crtLevelMap.keySet().iterator(); it.hasNext();)
						{
							if (level.compareTo(it.next()) <= 0)
							{
								it.remove();
							}
						}
					}
				}
				else // if (!isEndMarker)  // FIXMEXLS we should not add level if it is an end marker
				{
					//the level group is not yet open

					//we check to see if this level is higher than existing levels
					if (crtLevelMap.size() > 0 && level.compareTo(crtLevelMap.firstKey()) < 0)
					{
						//the level is higher than existing levels, so it has to close them all
						setRowLevels(levelInfo, level);
						
						//clean up nested level groups as they were closed; the current one is not yet among them 
						for (Iterator<String> it = crtLevelMap.keySet().iterator(); it.hasNext();)
						{
							if (level.compareTo(it.next()) < 0)
							{
								it.remove();
							}
						}
					}
					
					//create the current level group
//					XlsRowLevelRange range = new XlsRowLevelRange();
//					range.setStartIndex(rowIndex);
					//range.setEndIndex(rowIndex);
					//range.setName(groupName);
					crtLevelMap.put(level, rowIndex);
				}
			}
		}

		levelInfo.setEndIndex(rowIndex);
	}
 
/**
 * createNatureSelector
 * 
 * @param parent
 */
protected void createNatureSelector(Composite parent)
{
	// grab nature label+id list
	SortedMap<String, String> natureMap = getNatureMap();

	// combo label
	Label label = new Label(parent, SWT.LEFT);
	label.setFont(parent.getFont());
	label.setText(Messages.ContentAssistPreferencePage_NatureComboLabel);

	// create combo
	natureCombo = new Combo(parent, SWT.READ_ONLY);
	natureCombo.setFont(parent.getFont());

	GridData gd = new GridData();
	gd.horizontalSpan = 1;
	gd.horizontalAlignment = GridData.FILL;
	natureCombo.setLayoutData(gd);

	// Selected nature, in case it's a property page.
	boolean isProjectPreference = isProjectPreferencePage();
	String primaryProjectNature = null;
	if (isProjectPreference)
	{
		try
		{
			String[] aptanaNatures = ResourceUtil.getAptanaNatures(getProject().getDescription());
			if (!ArrayUtil.isEmpty(aptanaNatures))
			{
				primaryProjectNature = aptanaNatures[0];
			}
		}
		catch (CoreException e)
		{
		}
	}
	// set combo list
	for (Map.Entry<String, String> entry : natureMap.entrySet())
	{
		if (primaryProjectNature != null)
		{
			// Select only the matching entry
			if (primaryProjectNature.equals(entry.getValue()))
			{
				natureCombo.add(entry.getKey());
				break;
			}
		}
		else
		{
			natureCombo.add(entry.getKey());
		}
	}

	// select first item and save reference to that nature id for future selection updates
	natureCombo.select(0);
	activeNatureID = natureMap.get(natureCombo.getText());

	natureCombo.setEnabled(!isProjectPreference);
	if (!isProjectPreference)
	{
		natureCombo.addSelectionListener(new SelectionAdapter()
		{
			public void widgetSelected(SelectionEvent evt)
			{
				// update selection in model
				userAgentsByNatureID.put(activeNatureID, getSelectedUserAgents());

				// update nature id
				activeNatureID = getNatureMap().get(natureCombo.getText());

				// update visible selection
				updateUserAgentSelection();
			}
		});
	}
}
 
源代码16 项目: jdk1.8-source-analysis   文件: EnvHelp.java
private static void hideAttributes(SortedMap<String, ?> map) {
    if (map.isEmpty())
        return;

    final SortedSet<String> hiddenStrings;
    final SortedSet<String> hiddenPrefixes;

    String hide = (String) map.get(HIDDEN_ATTRIBUTES);
    if (hide != null) {
        if (hide.startsWith("="))
            hide = hide.substring(1);
        else
            hide += " " + DEFAULT_HIDDEN_ATTRIBUTES;
        hiddenStrings = new TreeSet<String>();
        hiddenPrefixes = new TreeSet<String>();
        parseHiddenAttributes(hide, hiddenStrings, hiddenPrefixes);
    } else {
        hide = DEFAULT_HIDDEN_ATTRIBUTES;
        synchronized (defaultHiddenStrings) {
            if (defaultHiddenStrings.isEmpty()) {
                parseHiddenAttributes(hide,
                                      defaultHiddenStrings,
                                      defaultHiddenPrefixes);
            }
            hiddenStrings = defaultHiddenStrings;
            hiddenPrefixes = defaultHiddenPrefixes;
        }
    }

    /* Construct a string that is greater than any key in the map.
       Setting a string-to-match or a prefix-to-match to this string
       guarantees that we will never call next() on the corresponding
       iterator.  */
    String sentinelKey = map.lastKey() + "X";
    Iterator<String> keyIterator = map.keySet().iterator();
    Iterator<String> stringIterator = hiddenStrings.iterator();
    Iterator<String> prefixIterator = hiddenPrefixes.iterator();

    String nextString;
    if (stringIterator.hasNext())
        nextString = stringIterator.next();
    else
        nextString = sentinelKey;
    String nextPrefix;
    if (prefixIterator.hasNext())
        nextPrefix = prefixIterator.next();
    else
        nextPrefix = sentinelKey;

    /* Read each key in sorted order and, if it matches a string
       or prefix, remove it. */
keys:
    while (keyIterator.hasNext()) {
        String key = keyIterator.next();

        /* Continue through string-match values until we find one
           that is either greater than the current key, or equal
           to it.  In the latter case, remove the key.  */
        int cmp = +1;
        while ((cmp = nextString.compareTo(key)) < 0) {
            if (stringIterator.hasNext())
                nextString = stringIterator.next();
            else
                nextString = sentinelKey;
        }
        if (cmp == 0) {
            keyIterator.remove();
            continue keys;
        }

        /* Continue through the prefix values until we find one
           that is either greater than the current key, or a
           prefix of it.  In the latter case, remove the key.  */
        while (nextPrefix.compareTo(key) <= 0) {
            if (key.startsWith(nextPrefix)) {
                keyIterator.remove();
                continue keys;
            }
            if (prefixIterator.hasNext())
                nextPrefix = prefixIterator.next();
            else
                nextPrefix = sentinelKey;
        }
    }
}
 
源代码17 项目: jdk8u60   文件: EnvHelp.java
private static void hideAttributes(SortedMap<String, ?> map) {
    if (map.isEmpty())
        return;

    final SortedSet<String> hiddenStrings;
    final SortedSet<String> hiddenPrefixes;

    String hide = (String) map.get(HIDDEN_ATTRIBUTES);
    if (hide != null) {
        if (hide.startsWith("="))
            hide = hide.substring(1);
        else
            hide += " " + DEFAULT_HIDDEN_ATTRIBUTES;
        hiddenStrings = new TreeSet<String>();
        hiddenPrefixes = new TreeSet<String>();
        parseHiddenAttributes(hide, hiddenStrings, hiddenPrefixes);
    } else {
        hide = DEFAULT_HIDDEN_ATTRIBUTES;
        synchronized (defaultHiddenStrings) {
            if (defaultHiddenStrings.isEmpty()) {
                parseHiddenAttributes(hide,
                                      defaultHiddenStrings,
                                      defaultHiddenPrefixes);
            }
            hiddenStrings = defaultHiddenStrings;
            hiddenPrefixes = defaultHiddenPrefixes;
        }
    }

    /* Construct a string that is greater than any key in the map.
       Setting a string-to-match or a prefix-to-match to this string
       guarantees that we will never call next() on the corresponding
       iterator.  */
    String sentinelKey = map.lastKey() + "X";
    Iterator<String> keyIterator = map.keySet().iterator();
    Iterator<String> stringIterator = hiddenStrings.iterator();
    Iterator<String> prefixIterator = hiddenPrefixes.iterator();

    String nextString;
    if (stringIterator.hasNext())
        nextString = stringIterator.next();
    else
        nextString = sentinelKey;
    String nextPrefix;
    if (prefixIterator.hasNext())
        nextPrefix = prefixIterator.next();
    else
        nextPrefix = sentinelKey;

    /* Read each key in sorted order and, if it matches a string
       or prefix, remove it. */
keys:
    while (keyIterator.hasNext()) {
        String key = keyIterator.next();

        /* Continue through string-match values until we find one
           that is either greater than the current key, or equal
           to it.  In the latter case, remove the key.  */
        int cmp = +1;
        while ((cmp = nextString.compareTo(key)) < 0) {
            if (stringIterator.hasNext())
                nextString = stringIterator.next();
            else
                nextString = sentinelKey;
        }
        if (cmp == 0) {
            keyIterator.remove();
            continue keys;
        }

        /* Continue through the prefix values until we find one
           that is either greater than the current key, or a
           prefix of it.  In the latter case, remove the key.  */
        while (nextPrefix.compareTo(key) <= 0) {
            if (key.startsWith(nextPrefix)) {
                keyIterator.remove();
                continue keys;
            }
            if (prefixIterator.hasNext())
                nextPrefix = prefixIterator.next();
            else
                nextPrefix = sentinelKey;
        }
    }
}
 
源代码18 项目: netbeans   文件: ResourcesTest.java
/** If package contains only one resource it is not too frendly to our classloaders.
     * Generally not a big problem OTOH we want to avoid this if this is simple.
     */
    public void testOneInPackage() throws Exception {
        SortedSet<Violation> violations = new TreeSet<Violation>();
        for (File f: org.netbeans.core.startup.Main.getModuleSystem().getModuleJars()) {
            // check JAR files only
            if (!f.getName().endsWith(".jar"))
                continue;
            
            // ignore branding
            if (f.getName().endsWith("_nb.jar"))
                continue;
            
            // a lot of alarms for 3rd party JARs
            if (f.getName().contains("modules/ext/"))
                continue;
            
            SortedMap<String, Integer> resourcesPerPackage = new TreeMap<String, Integer>();
            JarFile jar = new JarFile(f);
            Enumeration<JarEntry> entries = jar.entries();
            JarEntry entry;
            int entryCount = 0;
            while (entries.hasMoreElements()) {
                entry = entries.nextElement();
                if (entry.isDirectory())
                    continue;
                
                String name = entry.getName();
                String prefix = (name.lastIndexOf('/') >= 0)?
                    name.substring(0, name.lastIndexOf('/')): "";
                if (prefix.startsWith("META-INF")
                || prefix.startsWith("1.0/")
                || prefix.startsWith("com/")
                || prefix.startsWith("javax/")
                || prefix.startsWith("freemarker/")
                || prefix.startsWith("org/apache/tomcat")
                || prefix.startsWith("org/apache/lucene")
                || prefix.startsWith("org/w3c/")
//                || prefix.startsWith("")
                || prefix.startsWith("org/netbeans/modules/openide/actions")
                || prefix.startsWith("org/netbeans/modules/openide/awt")
                || prefix.startsWith("org/netbeans/modules/openide/windows")
                || prefix.startsWith("org/openide/explorer/propertysheet") // in deprecated core/settings
                || prefix.startsWith("org/openide/io")
                || prefix.startsWith("org/netbeans/api")
                || prefix.startsWith("org/netbeans/spi")
                || prefix.startsWith("org/netbeans/core/execution/beaninfo")
                || prefix.startsWith("org/netbeans/modules/web/monitor")
                || prefix.matches("org/netbeans/.*/[as]pi.*")
                        ) {
                    continue;
                }
                
                entryCount++;
                Integer count = resourcesPerPackage.get(prefix);
                if (count != null) {
                    resourcesPerPackage.put(prefix, count+1);
                }
                else {
                    resourcesPerPackage.put(prefix, 1);
                }
            }
            if (entryCount > 1) { // filter library wrappes (they have only Bundle.properties)
                for (Map.Entry<String, Integer> pkgInfo: resourcesPerPackage.entrySet()) {
                    if (pkgInfo.getValue().equals(1)) {
                        violations.add(new Violation(pkgInfo.getKey(), jar.getName(), " has package with just one resource"));
                    }
                }
            }
        }
        if (!violations.isEmpty()) {
            StringBuilder msg = new StringBuilder();
            msg.append("Some JARs in IDE contains sparsely populated packages ("+violations.size()+"):\n");
            for (Violation viol: violations) {
                msg.append(viol).append('\n');
            }
            fail(msg.toString());
        }
        //                    assertTrue (entry.toString()+" should have line number table", v.foundLineNumberTable());
    }
 
源代码19 项目: libreveris   文件: ScoreXmlReduction.java
/**
 * Create the header of the global partwise, by replicating information
 * form first page header
 *
 * @param global the global partwise to update
 * @param pages  the individual page partwise instances
 */
private void addHeader (ScorePartwise global,
                        SortedMap<Integer, ScorePartwise> pages)
{
    //
    //  <!ENTITY % score-header
    //          "(work?, movement-number?, movement-title?,
    //            identification?, defaults?, credit*, part-list)">
    //

    // First page data
    ScorePartwise first = pages.get(pages.firstKey());

    // work?
    if (first.getWork() != null) {
        global.setWork(first.getWork());
    }

    // movement-number?
    if (first.getMovementNumber() != null) {
        global.setMovementNumber(first.getMovementNumber());
    }

    // movement-title?
    if (first.getMovementTitle() != null) {
        global.setMovementTitle(first.getMovementTitle());
    }

    // identification?
    if (first.getIdentification() != null) {
        // TODO Encoding:
        // - Signature is inserted twice (page then global)
        // - Source should be the whole score file, not the first page file
        global.setIdentification(first.getIdentification());
    }

    // defaults?
    if (first.getDefaults() != null) {
        global.setDefaults(first.getDefaults());
    }

    // credit(s) for first page and others as well
    for (Entry<Integer, ScorePartwise> entry : pages.entrySet()) {
        int index = entry.getKey();
        ScorePartwise page = entry.getValue();
        List<Credit> credits = page.getCredit();

        if (!credits.isEmpty()) {
            // Add page index
            insertPageIndex(index, credits);
            global.getCredit().addAll(credits);
        }
    }
}
 
源代码20 项目: sis   文件: Loggers.java
/**
 * Returns a map of effective logging levels for SIS loggers. The effective logging level take in account the level
 * of parent loggers and the level of handlers. For example if a logger level is set to {@link Level#FINE} but no
 * handler have a level finer than {@link Level#INFO}, then the effective logging level will be {@link Level#INFO}.
 *
 * <p>This method does not report the loggers that have an effective level identical to its parent logger.</p>
 *
 * @return the effective logging levels of SIS loggers.
 */
public static SortedMap<String,Level> getEffectiveLevels() {
    final SortedMap<String,Level> levels = new TreeMap<>();
    for (final Field field : Loggers.class.getDeclaredFields()) {
        if (Modifier.isStatic(field.getModifiers()) && field.getType() == String.class) try {
            levels.put((String) field.get(null), null);
        } catch (IllegalAccessException e) {
            /*
             * Should never happen, unless we added some fields and forgot to update this method.
             * In such case forget the problematic fields and search the next one. This is okay
             * since this method is only for information purpose.
             */
            Logging.unexpectedException(Logging.getLogger(SYSTEM), Loggers.class, "getEffectiveLevels", e);
        }
    }
    /*
     * Process the loggers in alphabetical order. The intent is to process parent loggers before child.
     * The first logger in the map should be the SIS root logger, "org.apache.sis".
     */
    final Iterator<Map.Entry<String,Level>> it = levels.entrySet().iterator();
    while (it.hasNext()) {
        final Map.Entry<String,Level> entry = it.next();
        final String name = entry.getKey();
        final Logger logger = Logging.getLogger(name);
        Level level = getEffectiveLevel(logger);
        final Level h = getHandlerLevel(logger);
        if (h.intValue() > level.intValue()) {
            level = h;                              // Take in account the logging level of handlers.
        }
        entry.setValue(level);
        /*
         * Now verify if the level is identical to the effective level of parent logger.
         * If they are identical, then we remove the entry in order to report only the changes.
         */
        Logger parent = logger;
        while ((parent = parent.getParent()) != null) {
            final Level p = levels.get(parent.getName());
            if (p != null) {
                if (p.equals(level)) {
                    it.remove();
                }
                break;
            }
        }
    }
    return levels;
}