Example usage for org.apache.commons.lang3.mutable MutableInt intValue

List of usage examples for org.apache.commons.lang3.mutable MutableInt intValue

Introduction

In this page you can find the example usage for org.apache.commons.lang3.mutable MutableInt intValue.

Prototype

@Override
public int intValue() 

Source Link

Document

Returns the value of this MutableInt as an int.

Usage

From source file:com.datatorrent.lib.appdata.gpo.SerdeListString.java

@Override
public synchronized Object deserializeObject(byte[] object, MutableInt offset) {
    int length = GPOUtils.deserializeInt(object, offset);
    int startIndex = offset.intValue();

    List<String> strings = Lists.newArrayList();
    while (startIndex + length > offset.intValue()) {
        String value = GPOUtils.deserializeString(object, offset);
        strings.add(value);/*w  w w . j  av a2  s  .  co  m*/
    }

    return strings;
}

From source file:com.datatorrent.lib.appdata.gpo.SerdeListPrimitive.java

@Override
public synchronized Object deserializeObject(byte[] object, MutableInt offset) {
    int length = GPOUtils.deserializeInt(object, offset);
    int startIndex = offset.intValue();

    List<Object> listPrimitives = Lists.newArrayList();

    while (startIndex + length > offset.intValue()) {
        int typeOrdinal = GPOUtils.deserializeInt(object, offset);
        GPOType gpoType = GPOType.GPO_TYPE_ARRAY[typeOrdinal];
        Object primitive = gpoType.deserialize(object, offset);
        listPrimitives.add(primitive);/*from ww  w. j a va2  s .  c  om*/
    }

    return listPrimitives;
}

From source file:com.datatorrent.lib.appdata.gpo.SerdeListGPOMutable.java

@Override
public synchronized Object deserializeObject(byte[] object, MutableInt offset) {
    int length = GPOUtils.deserializeInt(object, offset);
    int startIndex = offset.intValue();

    if (length == 0) {
        return new ArrayList<GPOMutable>();
    }//from   w  w w.  j  a v  a2s . co m

    FieldsDescriptor fd = (FieldsDescriptor) SerdeFieldsDescriptor.INSTANCE.deserializeObject(object, offset);

    List<GPOMutable> mutables = Lists.newArrayList();
    while (startIndex + length > offset.intValue()) {
        GPOMutable value = GPOUtils.deserialize(fd, object, offset);
        mutables.add(value);
    }

    return mutables;
}

From source file:com.datatorrent.lib.appdata.gpo.SerdeMapPrimitive.java

@Override
public synchronized Object deserializeObject(byte[] objectBytes, MutableInt offset) {
    int length = GPOUtils.deserializeInt(objectBytes, offset);
    int startIndex = offset.intValue();

    Map<Object, Object> primitiveMap = Maps.newHashMap();

    while (startIndex + length > offset.intValue()) {
        int typeOrdinal = GPOUtils.deserializeInt(objectBytes, offset);
        GPOType gpoType = GPOType.GPO_TYPE_ARRAY[typeOrdinal];
        Object key = gpoType.deserialize(objectBytes, offset);

        typeOrdinal = GPOUtils.deserializeInt(objectBytes, offset);
        gpoType = GPOType.GPO_TYPE_ARRAY[typeOrdinal];
        Object value = gpoType.deserialize(objectBytes, offset);
        primitiveMap.put(key, value);/*from  w w w.  j  a  va2 s . co m*/
    }

    return primitiveMap;
}

From source file:com.addthis.hydra.data.query.QueryElementProperty.java

public QueryElementProperty parse(String tok, MutableInt nextColumn) {
    if (tok.startsWith("+")) {
        // show = true;
        column = Integer.toString(nextColumn.intValue());
        nextColumn.increment();/*from w w  w  . j a  v  a  2  s.c o  m*/
        tok = tok.substring(1);
    }
    key = new BoundedValue().parse(tok, nextColumn);
    return this;
}

From source file:com.datatorrent.lib.appdata.gpo.SerdeFieldsDescriptor.java

@Override
public synchronized Object deserializeObject(byte[] object, MutableInt offset) {
    Map<String, Type> fieldToType = Maps.newHashMap();

    int length = GPOUtils.deserializeInt(object, offset);
    int startIndex = offset.intValue();

    while (startIndex + length > offset.intValue()) {
        Type type = Type.values()[GPOUtils.deserializeInt(object, offset)];
        String value = GPOUtils.deserializeString(object, offset);

        fieldToType.put(value, type);//w w  w . j  a va  2s.  c om
    }

    return new FieldsDescriptor(fieldToType);
}

From source file:com.mgmtp.jfunk.core.mail.MailArchiver.java

/**
 * Saves a message's test content (including headers) in the current module archive in the specified sub-directory relative to
 * the archive root. File names are prefixed with a left-padded four-digit integer counter (format: {@code %04d_%s.txt}).
 * /*  www  . j a va 2 s  .  com*/
 * @param message
 *            the message
 * @return the file the e-mail was written to
 */
public File archiveMessage(final MailMessage message) {
    try {
        String subject = message.getSubject();
        String fileName = subject == null ? "no_subject"
                : INVALID_FILE_NAME_CHARS.matcher(subject).replaceAll("_");

        MutableInt counter = counterProvider.get();
        File dir = new File("e-mails", "unread");
        File file = new File(dir, String.format(FILE_NAME_FORMAT, counter.intValue(), fileName));
        file = new File(moduleArchiveDirProvider.get(), file.getPath());
        createParentDirs(file);
        log.debug("Archiving e-mail: {}", file);

        StrBuilder sb = new StrBuilder(500);
        for (Entry<String, String> header : message.getHeaders().entries()) {
            sb.append(header.getKey()).append('=').appendln(header.getValue());
        }
        sb.appendln("");
        sb.append(message.getText());

        write(sb.toString(), file, Charsets.UTF_8);
        counter.increment();

        return file;
    } catch (IOException ex) {
        throw new MailException("Error archiving mail.", ex);
    }
}

From source file:com.mgmtp.jfunk.core.util.ScreenCapturer.java

/**
 * Takes a screenshot and stores it in folder {@code screenshots} in the current module's
 * archive directory. The screenshot image is named by the specified screenshot name, prefixed
 * with a left-padded four-digit integer counter (format: {@code %04d_%s.png}).
 * /*from  ww w . ja  va 2s.c om*/
 * @param screenshotName
 *            the name of the screenshot
 */
public void captureAndArchiveScreen(final String screenshotName) {
    MutableInt counter = counterProvider.get();
    String relativePath = String.format(SCREENSHOT_PATH_FORMAT, counter.intValue(), screenshotName);
    captureScreen(new File(moduleArchiveDirProvider.get(), relativePath));
    counter.increment();
}

From source file:com.addthis.hydra.data.query.QueryElementField.java

public QueryElementField parse(String tok, MutableInt nextColumn) {
    if (tok.startsWith("+")) {
        // show = true;
        column = Integer.toString(nextColumn.intValue());
        nextColumn.increment();//from   w  w  w . j a v a 2 s .c  o m
        tok = tok.substring(1);
    } else if (tok.startsWith("?")) {
        // show = true;
        column = Integer.toString(nextColumn.intValue());
        nextColumn.increment();
        tok = tok.substring(1);
        keys = memKey;
    }
    String[] kv = LessStrings.splitArray(LessBytes.urldecode(tok), "=");
    if (kv.length == 2) {
        name = kv[0];
        String[] keyarr = LessStrings.splitArray(kv[1], ",");
        keys = new BoundedValue[keyarr.length];
        for (int i = 0; i < keyarr.length; i++) {
            keys[i] = new BoundedValue().parse(keyarr[i], nextColumn);
        }
    } else if (kv.length == 1) {
        name = kv[0];
        if (keys == null) {
            keys = new BoundedValue[1];
            keys[0] = new BoundedValue();
        }
    }
    return this;
}

From source file:events.TeamVsTeam.TeamVsTeam.java

/**
 * @param player/* w  w  w.  jav a 2  s. c o m*/
 * @return Returns personal player score
 */
public static int getPlayerScore(Player player) {
    MutableInt points = score.get(player.getObjectId());
    return points.intValue();
}