Example usage for java.lang String intern

List of usage examples for java.lang String intern

Introduction

In this page you can find the example usage for java.lang String intern.

Prototype

public native String intern();

Source Link

Document

Returns a canonical representation for the string object.

Usage

From source file:org.protempa.proposition.AbstractProposition.java

public final void setProperty(String name, Value value) {
    if (name == null) {
        throw new IllegalArgumentException("name cannot be null");
    }//from   w  w w. ja  v  a 2  s  .c o  m
    initializeProperties();
    this.properties.put(name.intern(), value);
}

From source file:org.lealone.cluster.gms.VersionedValue.java

private VersionedValue(String value, int version) {
    assert value != null;
    // blindly interning everything is somewhat suboptimal -- lots of VersionedValues are unique --
    // but harmless, and interning the non-unique ones saves significant memory.  (Unfortunately,
    // we don't really have enough information here in VersionedValue to tell the probably-unique
    // values apart.)  See Cassandra-6410.
    this.value = value.intern();
    this.version = version;
}

From source file:com.thoughtworks.go.server.controller.ArtifactsController.java

private boolean updateChecksumFile(MultipartHttpServletRequest request, JobIdentifier jobIdentifier,
        String filePath) throws IOException, IllegalArtifactLocationException {
    MultipartFile checksumMultipartFile = getChecksumFile(request);
    if (checksumMultipartFile != null) {
        String checksumFilePath = String.format("%s/%s/%s", artifactsService.findArtifactRoot(jobIdentifier),
                ArtifactLogUtil.CRUISE_OUTPUT_FOLDER, ArtifactLogUtil.MD5_CHECKSUM_FILENAME);
        File checksumFile = artifactsService.getArtifactLocation(checksumFilePath);
        synchronized (checksumFilePath.intern()) {
            return artifactsService.saveOrAppendFile(checksumFile, checksumMultipartFile.getInputStream());
        }//from ww w  . j av a2s.  c om
    } else {
        LOGGER.warn("[Artifacts Upload] Checksum file not uploaded for artifact at path '{}'", filePath);
    }
    return true;
}

From source file:org.protempa.backend.dsb.relationaldb.PropertySpec.java

/**
 * Instantiates a property specification with a name, path, value type,
 * optional mappings from values in the database to values as
 * specified in a knowledge source, and a custom formatter for reading
 * values of this property from a result set.
 * //from   ww w.j av a2  s .co  m
 * @param name the property's name. Cannot be <code>null</code>.
 * @param codeToPropIdMap an optional {@link Map<String,String>()} map
 * from values in the database to values in a knowledge source.
 * @param codeSpec a {@link ColumnSpec} path through the database from
 * the corresponding entity's main table to the table and column where this
 * property is located.
 * @param valueType the {@link ValueType} type of values of this property.
 * @param jdbcValueFormat a {@link JDBCValueFormat} for reading values of
 * this property from a result set (may be null).
 */
public PropertySpec(String name, Map<String, String> codeToPropIdMap, ColumnSpec codeSpec,
        ColumnSpec constraintSpec, ValueType valueType, JDBCValueFormat jdbcValueFormat) {
    if (name == null)
        throw new IllegalArgumentException("name cannot be null");
    if (codeSpec == null)
        throw new IllegalArgumentException("codeSpec cannot be null");
    if (valueType == null)
        throw new IllegalArgumentException("valueType cannot be null");
    this.name = name.intern();
    if (codeToPropIdMap != null) {
        this.codeToPropIdMap = new HashMap<>(codeToPropIdMap);
    } else {
        this.codeToPropIdMap = Collections.emptyMap();
    }
    this.codeSpec = codeSpec;
    this.valueType = valueType;
    this.constraintSpec = constraintSpec;
    this.jdbcValueFormat = jdbcValueFormat;
}

From source file:org.protempa.proposition.AbstractProposition.java

public final void setReferences(String name, List<UniqueId> refs) {
    if (name == null) {
        throw new IllegalArgumentException("name cannot be null");
    }// ww w . ja  v a  2s .  c o  m
    initializeReferences();
    this.references.put(name.intern(), new ArrayList<>(refs));
}

From source file:org.blockartistry.DynSurround.client.footsteps.implem.BlockMap.java

private void put(@Nonnull final Block block, final int meta, @Nonnull final String substrate,
        @Nonnull final String value) {

    final IAcoustic[] acoustics = this.isolator.getAcoustics().compileAcoustics(value);

    if (StringUtils.isEmpty(substrate)) {
        this.metaMap.put(new BlockInfo(block, meta), acoustics);
    } else {// w w w  .  j a v a  2 s  .  c  o m
        BlockAcousticMap sub = this.substrateMap.get(substrate);
        if (sub == null)
            this.substrateMap.put(substrate.intern(), sub = new BlockAcousticMap());
        sub.put(new BlockInfo(block, meta), acoustics);
    }
}

From source file:org.apache.cassandra.gms.VersionedValue.java

private VersionedValue(String value, int version) {
    assert value != null;
    // blindly interning everything is somewhat suboptimal -- lots of VersionedValues are unique --
    // but harmless, and interning the non-unique ones saves significant memory.  (Unfortunately,
    // we don't really have enough information here in VersionedValue to tell the probably-unique
    // values apart.)  See CASSANDRA-6410.
    this.value = value.intern();
    this.version = version;
}

From source file:org.opennms.netmgt.config.datacollection.Rrd.java

/**
 * //from  ww  w  . ja va 2s.  com
 * 
 * @param index
 * @param rra
 * @throws IndexOutOfBoundsException if the index
 * given is outside the bounds of the collection
 */
public void setRra(final int index, final String rra) throws IndexOutOfBoundsException {
    if (index < 0 || index >= m_rras.size()) {
        throw new IndexOutOfBoundsException(
                "setRra: Index value '" + index + "' not in range [0.." + (m_rras.size() - 1) + "]");
    }
    m_rras.set(index, rra.intern());
}

From source file:org.dhatim.delivery.dom.DOMBuilder.java

public void startElement(StartElementEvent startEvent) throws SAXException {
    Element newElement = null;/*from w w  w.  j  a va 2 s . c om*/
    int attsCount = startEvent.atts.getLength();
    Node currentNode = (Node) nodeStack.peek();

    try {
        if (startEvent.uri != null && startEvent.qName != null && !startEvent.qName.equals("")) {
            newElement = ownerDocument.createElementNS(startEvent.uri.intern(), startEvent.qName);
        } else {
            newElement = ownerDocument.createElement(startEvent.localName.intern());
        }

        currentNode.appendChild(newElement);
        if (!emptyElements.contains(startEvent.qName != null ? startEvent.qName : startEvent.localName)) {
            nodeStack.push(newElement);
        }
    } catch (DOMException e) {
        logger.error("DOMException creating start element: namespaceURI=" + startEvent.uri + ", localName="
                + startEvent.localName, e);
        throw e;
    }

    for (int i = 0; i < attsCount; i++) {
        String attNamespace = startEvent.atts.getURI(i);
        String attQName = startEvent.atts.getQName(i);
        String attLocalName = startEvent.atts.getLocalName(i);
        String attValue = startEvent.atts.getValue(i);
        try {
            if (attNamespace != null && attQName != null) {
                attNamespace = attNamespace.intern();
                if (attNamespace.equals(XMLConstants.NULL_NS_URI)) {
                    if (attQName.startsWith(XMLConstants.XMLNS_ATTRIBUTE)) {
                        attNamespace = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
                    } else if (attQName.startsWith("xml:")) {
                        attNamespace = XMLConstants.XML_NS_URI;
                    }
                }
                newElement.setAttributeNS(attNamespace, attQName, attValue);
            } else {
                newElement.setAttribute(attLocalName.intern(), attValue);
            }
        } catch (DOMException e) {
            logger.error("DOMException setting element attribute " + attLocalName + "=" + attValue
                    + "[namespaceURI=" + startEvent.uri + ", localName=" + startEvent.localName + "].", e);
            throw e;
        }
    }
}

From source file:org.apache.hadoop.chukwa.datastore.ViewStore.java

public static JSONArray list(String uid) throws IllegalAccessException {
    StringBuilder viewPath = new StringBuilder();
    viewPath.append(usersViewPath);//www . j  a v a  2s.c  o  m
    viewPath.append(File.separator);
    viewPath.append(uid);
    String[] pathList = new String[2];
    pathList[0] = viewPath.toString();
    pathList[1] = publicViewPath;
    JSONArray list = new JSONArray();
    for (String path : pathList) {
        Path viewFile = new Path(path);
        try {
            FileSystem fs = FileSystem.get(config);
            FileStatus[] fstatus = fs.listStatus(viewFile);
            if (fstatus != null) {
                for (int i = 0; i < fstatus.length; i++) {
                    long size = fstatus[i].getLen();
                    FSDataInputStream viewStream = fs.open(fstatus[i].getPath());
                    byte[] buffer = new byte[(int) size];
                    viewStream.readFully(buffer);
                    viewStream.close();
                    try {
                        ViewBean view = new ViewBean(new JSONObject(new String(buffer)));
                        JSONObject json = new JSONObject();
                        json.put("name", view.getName());
                        json.put("type", view.getPermissionType());
                        json.put("owner", view.getOwner());
                        if (uid.intern() == view.getOwner().intern()) {
                            json.put("editable", "true");
                        } else {
                            json.put("editable", "false");
                        }
                        list.put(json);
                    } catch (Exception e) {
                        log.error(ExceptionUtil.getStackTrace(e));
                    }
                }
            }
        } catch (IOException ex) {
            log.error(ExceptionUtil.getStackTrace(ex));
            throw new IllegalAccessException("Unable to access user view.");
        }
    }
    return list;
}