List of usage examples for java.lang String intern
public native String intern();
From source file:org.opennms.netmgt.config.datacollection.SnmpCollection.java
/** * Sets the value of field 'snmpStorageFlag'. The field * 'snmpStorageFlag' has the following description: indicates * if collected SNMP data is to be stored for * "all" interfaces or only for the "primary" * interface.//from w ww.j av a2 s .co m * * @param snmpStorageFlag the value of field 'snmpStorageFlag'. */ public void setSnmpStorageFlag(final String snmpStorageFlag) { m_snmpStorageFlag = snmpStorageFlag.intern(); }
From source file:org.eclipse.gyrex.http.application.Application.java
/** * Creates a new application instance.//from ww w . j a v a2 s . c o m * * @param id * the application id * @param context * the context */ protected Application(final String id, final IRuntimeContext context) { if (null == id) { throw new IllegalArgumentException("id must not be null"); } if (null == context) { throw new IllegalArgumentException("context must not be null"); } this.id = id.intern(); this.context = context; }
From source file:org.protempa.backend.dsb.relationaldb.ReferenceSpec.java
/** * Instantiates a reference instance with the reference's name, the * right-hand-side entity name and the paths to the tables and columns * that form the right-hand-side entity's unique identifier. * * @param referenceName the name {@link String of ther reference. * @param entityName the name {@link String} of the entity being * referenced.// w w w . j a v a 2 s . c om * @param uniqueIdSpecs the {@link ColumnSpec[]} paths through the database * from an entity's main table to the tables and columns that together form * an unique identifier of the entities being referenced. */ public ReferenceSpec(String referenceName, String entityName, ColumnSpec[] uniqueIdSpecs, Type type) { if (referenceName == null) throw new IllegalArgumentException("referenceName cannot be null"); if (entityName == null) throw new IllegalArgumentException("entityName cannot be null"); if (uniqueIdSpecs == null) throw new IllegalArgumentException("uniqueIdSpecs cannot be null"); if (type == null) throw new IllegalArgumentException("type cannot be null"); this.uniqueIdSpecs = uniqueIdSpecs.clone(); ProtempaUtil.checkArray(this.uniqueIdSpecs, "uniqueIdSpecs"); this.referenceName = referenceName.intern(); this.entityName = entityName; this.type = type; }
From source file:org.wso2.andes.kernel.slot.SlotManagerClusterMode.java
/** * Get an ordered set of existing, assigned slots that overlap with the input slot range. * * @param queueName name of destination queue * @param startMsgID start message ID of input slot * @param endMsgID end message ID of input slot * @return TreeSet<Slot>c/*from w ww. j a v a 2 s . c o m*/ */ private TreeSet<Slot> getOverlappedAssignedSlots(String queueName, long startMsgID, long endMsgID) throws AndesException { TreeSet<Slot> overlappedSlots = new TreeSet<>(); TreeSet<Slot> assignedOverlappingSlots = new TreeSet<>(); String lockKey = queueName + SlotManagerClusterMode.class; synchronized (lockKey.intern()) { // Get all slots created for given queue name TreeSet<Slot> slotListForQueue = slotAgent.getAllSlotsByQueueName(queueName); // Check each slot for overlapped slots for (Slot slot : slotListForQueue) { if (endMsgID < slot.getStartMessageId()) { continue; // skip this one, its below our range } if (startMsgID > slot.getEndMessageId()) { continue; // skip this one, its above our range } if (SlotState.ASSIGNED == slot.getCurrentState()) { assignedOverlappingSlots.add(slot); } // Set slot as overlapped if not skipped slot.setAnOverlappingSlot(true); if (log.isDebugEnabled()) { log.debug("Marked already assigned slot as an overlapping slot. Slot= " + slot.getId()); } overlappedSlots.add(slot); if (log.isDebugEnabled()) { log.debug("Found an overlapping slot : " + slot); } } slotAgent.updateOverlappedSlots(queueName, assignedOverlappingSlots); } return overlappedSlots; }
From source file:org.protempa.dest.table.Reference.java
/** * Creates an instance that specifies traversals using the specified * reference from a proposition only to propositions with the given ids and * that satisfy the specified constraints. It also allows specifying a range * of propositions on the right-hand-side of the reference to be traversed * to (first and second, first through third, etc.). * * @param referenceName a reference name {@link String} A value of * <code>null</code> specifies that all references should be traversed. * @param propositionIds a {@link String[]} of proposition ids. An empty * * or <code>null</code> array specifies that all propositions on the * right-hand-side of a reference should be used. * @param constraints a {@link PropertyConstraint[]} of property constraints * on the propositions on the right-hand-side of a reference. An empty * or <code>null</code> array specifies that no constraints should be * applied./*from www. j a va 2s.c o m*/ * @param comparator a comparison function representing the total order to * apply to propositions on the right-hand-side of the reference when using * the <code>index</code> parameter. If <code>null</code> and an * <code>index</code> is specified, the total order is unspecified. * @param fromIndex the lower-bound on the positions of the propositions on * the right-hand-side of the reference to traverse to, inclusive, using the * ordering specified by the <code>comparator</code> argument. An index * of <code>-1</code> means that all propositions on the * right-hand-side will be traversed to. * @param toIndex the upper-bound on the positions of the propositions on * the right-hand-side of the reference to traverse to, exclusive, using the * ordering specified by the <code>comparator</code> argument. An index * of <code>-1</code> means that all propositions on the * right-hand-side will be traversed to. */ public Reference(String referenceName, String[] propositionIds, PropertyConstraint[] constraints, Comparator<Proposition> comparator, int fromIndex, int toIndex) { super(propositionIds, constraints, comparator, fromIndex, toIndex); if (referenceName == null) { throw new IllegalArgumentException("referenceName cannot be null"); } this.referenceNames = new String[] { referenceName.intern() }; }
From source file:org.protempa.PropertyDefinition.java
/** * Initializes the property definition with a displayName, a value type and a value set.//from www. jav a2s .com * * @param id an unique id {@link String}. Cannot be <code>null</code>. * @param displayName a displayName {@link String}. If <code>null</code>, * the <code>displayName</code> field is set to the value of the * <code>id</code> field. * @param valueType a {@link ValueType}. Cannot be <code>null</code>. * @param valueSetId the unique id of this property's {@link ValueSet}. * * @see ValueType#isCompatible(org.protempa.valueset.ValueSet) */ public PropertyDefinition(String propId, String id, String displayName, ValueType valueType, String valueSetId, String declaringPropId, Attribute[] attributes) { if (propId == null) { throw new IllegalArgumentException("propId cannot be null"); } if (id == null) { throw new IllegalArgumentException("id cannot be null"); } if (valueType == null) { throw new IllegalArgumentException("valueType cannot be null"); } if (declaringPropId == null) { throw new IllegalArgumentException("declaringPropId cannot be null"); } this.id = id.intern(); this.displayName = displayName != null ? displayName.intern() : this.id; this.propId = propId; this.valueType = valueType; this.valueSetId = valueSetId; this.declaringPropId = declaringPropId; if (attributes == null) { this.attributes = EMPTY_ATTRIBUTES; } else { this.attributes = attributes.clone(); } this.attributeMap = new HashMap<>(); for (Attribute attribute : this.attributes) { this.attributeMap.put(attribute.getName(), attribute); } }
From source file:org.wso2.carbon.user.core.common.DefaultRealmService.java
private UserRealm getUserRealmInternal(RealmConfiguration tenantRealmConfig) throws UserStoreException { UserRealm userRealm = null;// w ww.j a v a2s . c om int tenantId = tenantRealmConfig.getTenantId(); if (tenantId == MultitenantConstants.SUPER_TENANT_ID) { return bootstrapRealm; } userRealm = (UserRealm) realmCache.getUserRealm(tenantId, PRIMARY_TENANT_REALM); if (userRealm == null) { MultiTenantRealmConfigBuilder realmConfigBuilder = getMultiTenantRealmConfigBuilder(); if (realmConfigBuilder != null) { tenantRealmConfig = realmConfigBuilder.getRealmConfigForTenantToCreateRealm(bootstrapRealmConfig, tenantRealmConfig, tenantId); } String tenantDomain = null; try { tenantDomain = tenantManager.getDomain(tenantId); } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException( "Error occurred while retrieving tenant domain from tenant Id " + tenantId); } synchronized (tenantDomain.intern()) { userRealm = initializeRealm(tenantRealmConfig, tenantId); realmCache.addToCache(tenantId, PRIMARY_TENANT_REALM, userRealm); } } return userRealm; }
From source file:net.javacoding.xsearch.config.ServerConfiguration.java
/** * Sets the base directory.//from w w w . j a va 2s. c o m * * @param basedir the base directory * @throws java.lang.NullPointerException if configFile is null. */ public void setBasedir(String basedir) { this.basedir = (basedir == null ? null : basedir.intern()); isDirty = true; // If basedir is relative, then it is resolved against the directory // for the server configuration file baseDirectory = FileUtil.resolveFile(configFile.getParentFile(), basedir); }
From source file:de.tudarmstadt.ukp.dkpro.core.io.conll.ConllUReader.java
public void convert(JCas aJCas, BufferedReader aReader) throws IOException { if (readPos) { try {//from w ww .j a va 2 s . c o m posMappingProvider.configure(aJCas.getCas()); } catch (AnalysisEngineProcessException e) { throw new IOException(e); } } JCasBuilder doc = new JCasBuilder(aJCas); List<String[]> words; while ((words = readSentence(aReader)) != null) { if (words.isEmpty()) { // Ignore empty sentences. This can happen when there are multiple end-of-sentence // markers following each other. continue; } int sentenceBegin = doc.getPosition(); int sentenceEnd = sentenceBegin; int surfaceBegin = -1; int surfaceEnd = -1; String surfaceString = null; // Tokens, Lemma, POS Int2ObjectMap<Token> tokens = new Int2ObjectOpenHashMap<>(); Iterator<String[]> wordIterator = words.iterator(); while (wordIterator.hasNext()) { String[] word = wordIterator.next(); if (word[ID].contains("-")) { String[] fragments = word[ID].split("-"); surfaceBegin = Integer.valueOf(fragments[0]); surfaceEnd = Integer.valueOf(fragments[1]); surfaceString = word[FORM]; continue; } // Read token int tokenIdx = Integer.valueOf(word[ID]); Token token = doc.add(word[FORM], Token.class); tokens.put(tokenIdx, token); if (!StringUtils.contains(word[MISC], "SpaceAfter=No") && wordIterator.hasNext()) { doc.add(" "); } // Read lemma if (!UNUSED.equals(word[LEMMA]) && readLemma) { Lemma lemma = new Lemma(aJCas, token.getBegin(), token.getEnd()); lemma.setValue(word[LEMMA]); lemma.addToIndexes(); token.setLemma(lemma); } // Read part-of-speech tag POS pos = null; String tag = useCPosAsPos ? word[CPOSTAG] : word[POSTAG]; if (!UNUSED.equals(tag) && readPos) { Type posTag = posMappingProvider.getTagType(tag); pos = (POS) aJCas.getCas().createAnnotation(posTag, token.getBegin(), token.getEnd()); pos.setPosValue(tag.intern()); } // Read coarse part-of-speech tag if (!UNUSED.equals(word[CPOSTAG]) && readCPos && pos != null) { pos.setCoarseValue(word[CPOSTAG].intern()); } if (pos != null) { pos.addToIndexes(); token.setPos(pos); } // Read morphological features if (!UNUSED.equals(word[FEATS]) && readMorph) { MorphologicalFeatures morphtag = new MorphologicalFeatures(aJCas, token.getBegin(), token.getEnd()); morphtag.setValue(word[FEATS]); morphtag.addToIndexes(); token.setMorph(morphtag); // Try parsing out individual feature values. Since the DKPro Core // MorphologicalFeatures type is based on the definition from the UD project, // we can do this rather straightforwardly. Type morphType = morphtag.getType(); String[] items = word[FEATS].split("\\|"); for (String item : items) { String[] keyValue = item.split("="); StringBuilder key = new StringBuilder(keyValue[0]); key.setCharAt(0, Character.toLowerCase(key.charAt(0))); String value = keyValue[1]; Feature feat = morphType.getFeatureByBaseName(key.toString()); if (feat != null) { morphtag.setStringValue(feat, value); } } } // Read surface form if (tokenIdx == surfaceEnd) { int begin = tokens.get(surfaceBegin).getBegin(); int end = tokens.get(surfaceEnd).getEnd(); SurfaceForm surfaceForm = new SurfaceForm(aJCas, begin, end); surfaceForm.setValue(surfaceString); surfaceForm.addToIndexes(); surfaceBegin = -1; surfaceEnd = -1; surfaceString = null; } sentenceEnd = token.getEnd(); } // Dependencies if (readDependency) { for (String[] word : words) { if (!UNUSED.equals(word[DEPREL])) { int depId = Integer.valueOf(word[ID]); int govId = Integer.valueOf(word[HEAD]); // Model the root as a loop onto itself makeDependency(aJCas, govId, depId, word[DEPREL], DependencyFlavor.BASIC, tokens, word); } if (!UNUSED.equals(word[DEPS])) { // list items separated by vertical bar String[] items = word[DEPS].split("\\|"); for (String item : items) { String[] sItem = item.split(":"); int depId = Integer.valueOf(word[ID]); int govId = Integer.valueOf(sItem[0]); makeDependency(aJCas, govId, depId, sItem[1], DependencyFlavor.ENHANCED, tokens, word); } } } } // Sentence Sentence sentence = new Sentence(aJCas, sentenceBegin, sentenceEnd); sentence.addToIndexes(); // Once sentence per line. doc.add("\n"); } doc.close(); }