Example usage for org.apache.commons.configuration DataConfiguration getInt

List of usage examples for org.apache.commons.configuration DataConfiguration getInt

Introduction

In this page you can find the example usage for org.apache.commons.configuration DataConfiguration getInt.

Prototype

public int getInt(String key) 

Source Link

Usage

From source file:gov.nih.nci.caarray.services.external.v1_0.data.impl.DataServiceBean.java

/**
 * {@inheritDoc}/*ww  w. j  ava2s . com*/
 */
@Override
public FileStreamableContents streamFileContents(CaArrayEntityReference fileRef, boolean compressed)
        throws InvalidReferenceException, DataTransferException {
    final CaArrayFile caarrayFile = getRequiredByExternalId(fileRef.getId(), CaArrayFile.class);
    RemoteInputStreamServer istream = null;
    final FileStreamableContents fsContents = new FileStreamableContents();
    fsContents.setMetadata(mapEntity(caarrayFile, File.class).getMetadata());
    fsContents.setCompressed(compressed);
    try {
        final InputStream is = this.dataStorageFacade.openInputStream(caarrayFile.getDataHandle(), compressed);
        final DataConfiguration config = ConfigurationHelper.getConfiguration();
        final int packetSize = config.getInt(ConfigParamEnum.FILE_RETRIEVAL_API_CHUNK_SIZE.name());
        istream = new SimpleRemoteInputStream(new BufferedInputStream(is));
        fsContents.setContentStream(istream.export());
        // after all the hard work, discard the local reference (we are passing
        // responsibility to the client)
        istream = null;

        return fsContents;
    } catch (final Exception e) {
        LOG.warn("Could not create input stream for file contents", e);
        throw new DataTransferException("Could not create input stream for file contents");
    } finally {
        // we will only close the stream here if the server fails before
        // returning an exported stream
        if (istream != null) {
            istream.close();
            // ARRAY-1958: close out temp files, if any
        }
    }
}

From source file:pl.otros.logview.gui.message.pattern.StyleProperties.java

public static Style getStyle(StyleContext styleContext, DataConfiguration styleConfig, String styleName,
        int group) {
    Style style = styleContext.addStyle(styleName, styleContext.getStyle(StyleContext.DEFAULT_STYLE));

    String groupSuffix = "." + group;
    if (group <= 0) {
        groupSuffix = "";
    }// w ww  .j  av a2 s.  c  o m

    String fontFamily = styleConfig.getString(PROP_FONT_FAMILY + groupSuffix, "");
    if (fontFamily.trim().length() > 0) {
        StyleConstants.setFontFamily(style, styleConfig.getString(PROP_FONT_FAMILY + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_SIZE + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setFontSize(style, styleConfig.getInt(PROP_FONT_SIZE + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_BOLD + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setBold(style, styleConfig.getBoolean(PROP_FONT_BOLD + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_ITALIC + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setItalic(style, styleConfig.getBoolean(PROP_FONT_ITALIC + groupSuffix));
    }

    if (styleConfig.getString(PROP_FONT_UNDERLINE + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setUnderline(style, styleConfig.getBoolean(PROP_FONT_UNDERLINE + groupSuffix));
    }

    if (styleConfig.getString(PROP_BACKGROUND + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix));
    }

    if (styleConfig.getString(PROP_FOREGROUND + groupSuffix, "").trim().length() > 0) {
        StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix));
    }
    return style;
}