try {
            return toJSON();
        } catch (JsonProcessingException e) {
            // this should never happen
            return super.toString();
        }

package edu.illinois.library.cantaloupe.image;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import edu.illinois.library.cantaloupe.Application;
import edu.illinois.library.cantaloupe.cache.DerivativeCache;
import edu.illinois.library.cantaloupe.processor.Processor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 *
Contains JSON-serializable information about an image, including its
 * format, dimensions, embedded metadata, subimages, and tile sizes—
 * essentially a superset of characteristics of all {@link Format formats}
 * supported by the application.

 *
 *
Instances are format-, {@link Processor}-, and endpoint-agnostic. An
 * instance describing a particular image {@link Processor#readInfo() returned
 * from one processor} should be {@link #equals equal} to an instance
 * describing the same image returned from a different processor. This
 * preserves the freedom to change processor assignments without invalidating
 * any {@link DerivativeCache#getInfo(Identifier) cached instances}.

 *
 *
All sizes are raw pixel data sizes, disregarding orientation.

 *
 *
Instances ultimately originate from {@link Processor#readInfo()}, but
 * subsequently they can be {@link DerivativeCache#put(Identifier, Info)
 * cached}, perhaps for a very long time. When an instance is needed, it may be
 * preferentially acquired from a cache, with a processor being consulted only
 * as a last resort. As a result, changes to the class definition need to be
 * implemented carefully so that {@link InfoDeserializer older serializations
 * remain readable}. (Otherwise, users might have to purge their cache whenever
 * the class design changes.)

 *
 *
History

 *
 *
See {@link Serialization}.

 */
@JsonSerialize(using = InfoSerializer.class)
@JsonDeserialize(using = InfoDeserializer.class)
public final class Info {

    public static final class Builder {

        private final Info info;

        Builder(Info info) {
            this.info = info;
        }

        public Info build() {
            return info;
        }

        public Builder withFormat(Format format) {
            info.setSourceFormat(format);
            return this;
        }

        public Builder withIdentifier(Identifier identifier) {
            info.setIdentifier(identifier);
            return this;
        }

        public Builder withMetadata(Metadata metadata) {
            info.setMetadata(metadata);
            return this;
        }

        public Builder withNumResolutions(int numResolutions) {
            info.setNumResolutions(numResolutions);
            return this;
        }

        public Builder withSize(Dimension size) {
            info.getImages().get(0).setSize(size);
            return this;
        }

        public Builder withSize(int width, int height) {
            return withSize(new Dimension(width, height));
        }

        public Builder withTileSize(Dimension size) {
            info.getImages().get(0).setTileSize(size);
            return this;
        }

        public Builder withTileSize(int width, int height) {
            return withTileSize(new Dimension(width, height));
        }
    }

    /**
     * Represents an embedded subimage within a container stream. This is a
     * physical image such as an embedded EXIF thumbnail or embedded TIFF page.
     */
    @JsonPropertyOrder({ "width", "height", "tileWidth", "tileHeight" })
    // this is from schema version <4
    @JsonIgnoreProperties({ "orientation" })
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static final class Image {

        public int width, height;

        public Integer tileWidth, tileHeight;

        @Override
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            } else if (obj instanceof Image) {
                final Image other = (Image) obj;
                return (width == other.width && height == other.height && Objects.equals(tileWidth, other.tileWidth) && Objects.equals(tileHeight, other.tileHeight));
            }
            return super.equals(obj);
        }

        /**
         * @return Physical image size.
         */
        @JsonIgnore
        public Dimension getSize() {
            return new Dimension(width, height);
        }

        /**
         * @return Physical tile size.
         */
        @JsonIgnore
        public Dimension getTileSize() {
            if (tileWidth != null && tileHeight != null) {
                return new Dimension(tileWidth, tileHeight);
            }
            return new Dimension(width, height);
        }

        @Override
        public int hashCode() {
            int[] codes = new int[] { width, height, tileWidth, tileHeight };
            return Arrays.hashCode(codes);
        }

        /**
         * @param size Physical image size.
         */
        public void setSize(Dimension size) {
            width = size.intWidth();
            height = size.intHeight();
        }

        /**
         * @param tileSize Physical image tile size.
         */
        public void setTileSize(Dimension tileSize) {
            tileWidth = tileSize.intWidth();
            tileHeight = tileSize.intHeight();
        }
    }

    public enum Serialization {

        /**
         * Represents a number of older serializations from application
         * versions prior to 3.4 that are no longer supported.
         */
        VERSION_1(1),
        /**
         *
Added the {@code mediaType} key.

         *
         *
Introduced in application version 3.4.

         */
        VERSION_2(2),
        /**
         *
Added {@code numResolutions} and {@code identifier} keys.

         *
         *
Introduced in application version 4.0.

         */
        VERSION_3(3),
        /**
         *
Replaced the {@code orientation} key with the {@code metadata}
         * key, and added {@code applicationVersion} and {@code
         * serializationVersion} keys.

         *
         *
Introduced in application version 5.0.

         */
        VERSION_4(4);

        private final int version;

        static final Serialization CURRENT = VERSION_4;

        Serialization(int version) {
            this.version = version;
        }

        int getVersion() {
            return version;
        }
    }

    private String appVersion = Application.getVersion();

    private Identifier identifier;

    private MediaType mediaType;

    private Metadata metadata = new Metadata();

    private Serialization serialization = Serialization.CURRENT;

    /**
     * Ordered list of subimages. The main image is at index {@code 0}.
     */
    private final List<Image> images = new ArrayList<>(8);

    /**
     * Number of resolutions available in the image. This applies to images
     * that may not have {@link #images literal embedded subimages}, but can
     * still be decoded at reduced scale factors.
     */
    private int numResolutions = -1;

    private transient boolean isPersistable = true;

    public static Builder builder() {
        return new Builder(new Info());
    }

    public static Info fromJSON(Path jsonFile) throws IOException {
        return newMapper().readValue(jsonFile.toFile(), Info.class);
    }

    public static Info fromJSON(InputStream jsonStream) throws IOException {
        return newMapper().readValue(jsonStream, Info.class);
    }

    public static Info fromJSON(String json) throws IOException {
        return newMapper().readValue(json, Info.class);
    }

    private static ObjectMapper newMapper() {
        ObjectMapper mapper = new ObjectMapper();
        // This module obscures Optionals from the serialization (e.g.
        mapper.registerModule(new Jdk8Module());
        return mapper;
    }

    public Info() {
        images.add(new Image());
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        } else if (obj instanceof Info) {
            Info other = (Info) obj;
            return Objects.equals(other.getApplicationVersion(), getApplicationVersion()) && Objects.equals(other.getSerialization(), getSerialization()) && Objects.equals(other.getIdentifier(), getIdentifier()) && Objects.equals(other.getMetadata(), getMetadata()) && Objects.equals(other.getSourceFormat(), getSourceFormat()) && other.getNumResolutions() == getNumResolutions() && other.getImages().equals(getImages());
        }
        return super.equals(obj);
    }

    /**
     * @return Version of the application with which the instance was or will
     *         be serialized.
     * @since 5.0
     * @see #getSerialization
     */
    public String getApplicationVersion() {
        return appVersion;
    }

    /**
     * @return Identifier. Will be {@code null} if the instance was serialized
     *         in an application version prior to 4.0.
     * @since 4.0
     */
    public Identifier getIdentifier() {
        return identifier;
    }

    public List<Image> getImages() {
        return images;
    }

    /**
     * For convenient serialization.
     *
     * @see #getSourceFormat()
     * @since 3.4
     */
    public MediaType getMediaType() {
        return mediaType;
    }

    public Metadata getMetadata() {
        return metadata;
    }

    /**
     * Returns the number of "pages" contained in the image. If the {@link
     * #getImages() images} appear to comprise a pyramid, this is {@code 1}.
     * Otherwise, it is equal to their count.
     *
     * @return Page count.
     * @since 5.0
     */
    public int getNumPages() {
        return isPyramid() ? 1 : getImages().size();
    }

    /**
     *
Returns the number of resolutions contained in the image.

     *
     *

     *
For formats like multi-resolution TIFF, this will match the size
     *     of {@link #getImages()}.

     *
For formats like JPEG2000, it will be {@code (number of
     *     decomposition levels) + 1}.

     *
For more conventional formats like JPEG, PNG, BMP, etc., it will
     *     be {@code 1}.

     *
For instances deserialized from a version older than 4.0, it
     *     will be {@code -1}.

     *

     *
     * @return Number of resolutions contained in the image, or {@code -1} if
     *         the instance was serialized in an older application version.
     * @since 4.0
     */
    public int getNumResolutions() {
        return numResolutions;
    }

    public Serialization getSerialization() {
        return serialization;
    }

    /**
     * @return Size of the main image.
     */
    public Dimension getSize() {
        return getSize(0);
    }

    /**
     * @return Size of the image at the given index.
     */
    public Dimension getSize(int imageIndex) {
        return images.get(imageIndex).getSize();
    }

    /**
     * @return Source format of the image, or {@link Format#UNKNOWN} if
     *         unknown.
     */
    public Format getSourceFormat() {
        if (mediaType != null) {
            return mediaType.toFormat();
        }
        return Format.UNKNOWN;
    }

    @Override
    public int hashCode() {
        int[] codes = new int[7];
        codes[0] = getApplicationVersion().hashCode();
        codes[1] = getSerialization().hashCode();
        codes[2] = getIdentifier().hashCode();
        codes[3] = getImages().hashCode();
        codes[4] = getSourceFormat().hashCode();
        codes[5] = getNumResolutions();
        if (getMetadata() != null) {
            codes[6] = getMetadata().hashCode();
        }
        return Arrays.hashCode(codes);
    }

    /**
     * @return Whether the instance contains complete and full information
     *         about the source image.
     * @since  5.0
     */
    public boolean isPersistable() {
        return isPersistable;
    }

    /**
     * @return Whether the {@link #getImages() images} appear to comprise a
     *         pyramid.
     * @since  5.0
     */
    boolean isPyramid() {
        List<Dimension> sizes = getImages().stream().map(Image::getSize).collect(Collectors.toUnmodifiableList());
        return Dimension.isPyramid(sizes);
    }

    /**
     * @param version Application version string. This value is not serialized
     *                (the {@link Application#getVersion() current application
     *                version} is instead).
     * @since         5.0
     */
    void setApplicationVersion(String version) {
        this.appVersion = version;
    }

    /**
     * @param identifier Identifier of the image described by the instance.
     * @since            4.0
     */
    public void setIdentifier(Identifier identifier) {
        this.identifier = identifier;
    }

    /**
     * For convenient deserialization.
     *
     * @see #setSourceFormat(Format)
     * @since 3.4
     */
    public void setMediaType(MediaType mediaType) {
        this.mediaType = mediaType;
    }

    public void setMetadata(Metadata metadata) {
        this.metadata = metadata;
    }

    /**
     * @param numResolutions Number of resolutions contained in the image.
     * @since 4.0
     */
    public void setNumResolutions(int numResolutions) {
        this.numResolutions = numResolutions;
    }

    /**
     * If a {@link Processor} cannot fully {@link Processor#readInfo()
     * populate} an instance—for example, if it can't read XMP metadata
     * in order to set a complete {@link #metadata}—then it should invoke
     * this method with a {@code false} argument to make that clear.
     *
     * @since 5.0
     */
    public void setPersistable(boolean isComplete) {
        this.isPersistable = isComplete;
    }

    /**
     * @param version One of the {@link Serialization} versions. This value is
     *                not serialized (the current serialization version is
     *                instead).
     * @since 5.0
     */
    void setSerializationVersion(int version) {
        this.serialization = Arrays.stream(Serialization.values()).filter(sv -> sv.getVersion() == version).findFirst().orElseThrow(IllegalArgumentException::new);
    }

    public void setSourceFormat(Format sourceFormat) {
        if (sourceFormat == null) {
            mediaType = null;
        } else {
            mediaType = sourceFormat.getPreferredMediaType();
        }
    }

    /**
     * @return JSON representation of the instance.
     */
    public String toJSON() throws JsonProcessingException {
        return newMapper().writer().writeValueAsString(this);
    }

    @Override
    public String toString() {

    }

    /**
     * @param os Output stream to write to.
     */
    public void writeAsJSON(OutputStream os) throws IOException {
        newMapper().writer().writeValue(os, this);
    }
}


public void syncSlaver(Table slaver, boolean delExtraFields) throws HongsException {
        List<String> sqls = this.deffSlaver(slaver, delExtraFields);
        DB sdb = slaver.db;
        sdb.begin();
        try {
            for (String sql : sqls) {
                sdb.execute(sql);
            }
            sdb.commit();
        } catch (HongsException ex) {
            sdb.revert();
            throw ex;
        }
    }

package io.github.ihongs.db.deff;

import io.github.ihongs.HongsException;
import io.github.ihongs.db.DB;
import io.github.ihongs.db.Table;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 表结构同步器(Table structure synchronizer)
 *
 * <b>注意: 参考MySQL编写, 可能不适用于其他数据库(使用了SHOW语句)</b>
 *
 * @author Hongs
 */
public class TableDeff {

    private final Table table;

    private final TableDesc tableDesc;

    /**
     * 通过表对象构造
     * @param table
     * @throws io.github.ihongs.HongsException
     */
    public TableDeff(Table table) throws HongsException {
        this.table = table;
        this.tableDesc = TableDesc.getInstance(table);
    }

    /**
     * 同步从表结构
     * @param slaver
     * @param delExtraFields 删除多余的字段
     * @throws io.github.ihongs.HongsException
     */

    public List<String> deffSlaver(Table slaver, boolean delExtraFields) throws HongsException {
        List sqls = new ArrayList();
        // 没有表则创建表
        String sql = "SHOW TABLES LIKE '" + slaver.tableName + "'";
        if (slaver.db.fetchAll(sql).isEmpty()) {
            sql = "SHOW CREATE TABLE `" + table.tableName + "`";
            sql = ((Map) table.db.fetchAll(sql).get(0)).get("Create Table").toString();
            sql = sql.replaceFirst("^CREATE TABLE `.*?`", "CREATE TABLE `" + slaver.tableName + "`");
            sqls.add(sql);
            return sqls;
        }
        TableDesc slaverDesc = TableDesc.getInstance(slaver);
        Iterator it;
        Map.Entry et;
        // 主键
        if (tableDesc.priCols.isEmpty()) {
            sql = tableDesc.alterPriKeySql(slaver.tableName, TableDesc.DROP);
            sqls.add(sql);
        }
        // 唯一键
        it = slaverDesc.uniKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            if (!tableDesc.uniKeys.containsKey(key)) {
                sql = tableDesc.alterUniKeySql(slaver.tableName, TableDesc.DROP, key);
                sqls.add(sql);
            }
        }
        // 索引键
        it = slaverDesc.idxKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            if (!tableDesc.idxKeys.containsKey(key)) {
                sql = tableDesc.alterIdxKeySql(slaver.tableName, TableDesc.DROP, key);
                sqls.add(sql);
            }
        }
        if (delExtraFields) {
            // 字段
            it = slaverDesc.columns.entrySet().iterator();
            while (it.hasNext()) {
                et = (Map.Entry) it.next();
                String col = (String) et.getKey();
                if (!tableDesc.columns.containsKey(col)) {
                    sql = tableDesc.alterColumnSql(slaver.tableName, TableDesc.DROP, col);
                    sqls.add(sql);
                }
            }
        }
        it = tableDesc.columns.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String col = (String) et.getKey();
            String dfn = (String) et.getValue();
            if (!slaverDesc.columns.containsKey(col)) {
                sql = tableDesc.alterColumnSql(slaver.tableName, TableDesc.ADD, col);
                sqls.add(sql);
            } else if (!dfn.equals(slaverDesc.columns.get(col))) {
                sql = tableDesc.alterColumnSql(slaver.tableName, TableDesc.MODIFY, col);
                sqls.add(sql);
            }
        }
        // 主键
        if (!tableDesc.priCols.isEmpty() && !tableDesc.priCols.equals(slaverDesc.priCols)) {
            sql = tableDesc.alterPriKeySql(slaver.tableName, TableDesc.ADD);
            sqls.add(sql);
        }
        // 唯一键
        it = tableDesc.uniKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            Set cols = (Set) et.getValue();
            if (!slaverDesc.uniKeys.containsKey(key) || !slaverDesc.uniKeys.get(key).equals(cols)) {
                sql = tableDesc.alterUniKeySql(slaver.tableName, TableDesc.ADD, key);
                sqls.add(sql);
            }
        }
        // 索引键
        it = tableDesc.idxKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            Set cols = (Set) et.getValue();
            if (!slaverDesc.idxKeys.containsKey(key) || !slaverDesc.idxKeys.get(key).equals(cols)) {
                sql = tableDesc.alterIdxKeySql(slaver.tableName, TableDesc.ADD, key);
                sqls.add(sql);
            }
        }
        return sqls;
    }
}


while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            Set cols = (Set) et.getValue();
            if (!slaverDesc.idxKeys.containsKey(key) || !slaverDesc.idxKeys.get(key).equals(cols)) {
                sql = tableDesc.alterIdxKeySql(slaver.tableName, TableDesc.ADD, key);
                sqls.add(sql);
            }
        }

package io.github.ihongs.db.deff;

import io.github.ihongs.HongsException;
import io.github.ihongs.db.DB;
import io.github.ihongs.db.Table;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 表结构同步器(Table structure synchronizer)
 *
 * <b>注意: 参考MySQL编写, 可能不适用于其他数据库(使用了SHOW语句)</b>
 *
 * @author Hongs
 */
public class TableDeff {

    private final Table table;

    private final TableDesc tableDesc;

    /**
     * 通过表对象构造
     * @param table
     * @throws io.github.ihongs.HongsException
     */
    public TableDeff(Table table) throws HongsException {
        this.table = table;
        this.tableDesc = TableDesc.getInstance(table);
    }

    /**
     * 同步从表结构
     * @param slaver
     * @param delExtraFields 删除多余的字段
     * @throws io.github.ihongs.HongsException
     */
    public void syncSlaver(Table slaver, boolean delExtraFields) throws HongsException {
        List<String> sqls = this.deffSlaver(slaver, delExtraFields);
        DB sdb = slaver.db;
        sdb.begin();
        try {
            for (String sql : sqls) {
                sdb.execute(sql);
            }
            sdb.commit();
        } catch (HongsException ex) {
            sdb.revert();
            throw ex;
        }
    }

    public List<String> deffSlaver(Table slaver, boolean delExtraFields) throws HongsException {
        List sqls = new ArrayList();
        // 没有表则创建表
        String sql = "SHOW TABLES LIKE '" + slaver.tableName + "'";
        if (slaver.db.fetchAll(sql).isEmpty()) {
            sql = "SHOW CREATE TABLE `" + table.tableName + "`";
            sql = ((Map) table.db.fetchAll(sql).get(0)).get("Create Table").toString();
            sql = sql.replaceFirst("^CREATE TABLE `.*?`", "CREATE TABLE `" + slaver.tableName + "`");
            sqls.add(sql);
            return sqls;
        }
        TableDesc slaverDesc = TableDesc.getInstance(slaver);
        Iterator it;
        Map.Entry et;
        // 主键
        if (tableDesc.priCols.isEmpty()) {
            sql = tableDesc.alterPriKeySql(slaver.tableName, TableDesc.DROP);
            sqls.add(sql);
        }
        // 唯一键
        it = slaverDesc.uniKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            if (!tableDesc.uniKeys.containsKey(key)) {
                sql = tableDesc.alterUniKeySql(slaver.tableName, TableDesc.DROP, key);
                sqls.add(sql);
            }
        }
        // 索引键
        it = slaverDesc.idxKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            if (!tableDesc.idxKeys.containsKey(key)) {
                sql = tableDesc.alterIdxKeySql(slaver.tableName, TableDesc.DROP, key);
                sqls.add(sql);
            }
        }
        if (delExtraFields) {
            // 字段
            it = slaverDesc.columns.entrySet().iterator();
            while (it.hasNext()) {
                et = (Map.Entry) it.next();
                String col = (String) et.getKey();
                if (!tableDesc.columns.containsKey(col)) {
                    sql = tableDesc.alterColumnSql(slaver.tableName, TableDesc.DROP, col);
                    sqls.add(sql);
                }
            }
        }
        it = tableDesc.columns.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String col = (String) et.getKey();
            String dfn = (String) et.getValue();
            if (!slaverDesc.columns.containsKey(col)) {
                sql = tableDesc.alterColumnSql(slaver.tableName, TableDesc.ADD, col);
                sqls.add(sql);
            } else if (!dfn.equals(slaverDesc.columns.get(col))) {
                sql = tableDesc.alterColumnSql(slaver.tableName, TableDesc.MODIFY, col);
                sqls.add(sql);
            }
        }
        // 主键
        if (!tableDesc.priCols.isEmpty() && !tableDesc.priCols.equals(slaverDesc.priCols)) {
            sql = tableDesc.alterPriKeySql(slaver.tableName, TableDesc.ADD);
            sqls.add(sql);
        }
        // 唯一键
        it = tableDesc.uniKeys.entrySet().iterator();
        while (it.hasNext()) {
            et = (Map.Entry) it.next();
            String key = (String) et.getKey();
            Set cols = (Set) et.getValue();
            if (!slaverDesc.uniKeys.containsKey(key) || !slaverDesc.uniKeys.get(key).equals(cols)) {
                sql = tableDesc.alterUniKeySql(slaver.tableName, TableDesc.ADD, key);
                sqls.add(sql);
            }
        }
        // 索引键
        it = tableDesc.idxKeys.entrySet().iterator();


public void setIndGuia(Byte value) {
        this.indGuia = value;
    }

// Este arquivo foi gerado pela Arquitetura JavaTM para Implementação de Referência (JAXB) de Bind XML, v2.2.8-b130911.1802
// Todas as modificações neste arquivo serão perdidas após a recompilação do esquema de origem.
package br.jus.tst.esocial.esquemas.eventos.baixa;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 * CHAVE_GRUPO: {indApuracao}, {perApur}, {indGuia}
 *
 *
Classe Java de T_ideEvento_folha_sem_retificacao complex type.
 *
 *
O seguinte fragmento do esquema especifica o conteúdo esperado contido dentro desta classe.
 *
 *

 * <complexType name="T_ideEvento_folha_sem_retificacao">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="indApuracao" type="{http://www.esocial.gov.br/schema/evt/evtBaixa/v_S_01_00_00}TS_indApuracao"/>
 *         <element name="perApur" type="{http://www.esocial.gov.br/schema/evt/evtBaixa/v_S_01_00_00}TS_perApur"/>
 *         <element name="indGuia" type="{http://www.esocial.gov.br/schema/evt/evtBaixa/v_S_01_00_00}TS_indGuia" minOccurs="0"/>
 *         <element name="tpAmb" type="{http://www.esocial.gov.br/schema/evt/evtBaixa/v_S_01_00_00}TS_tpAmb"/>
 *         <element name="procEmi" type="{http://www.esocial.gov.br/schema/evt/evtBaixa/v_S_01_00_00}TS_procEmi"/>
 *         <element name="verProc" type="{http://www.esocial.gov.br/schema/evt/evtBaixa/v_S_01_00_00}TS_verProc"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "T_ideEvento_folha_sem_retificacao", propOrder = { "indApuracao", "perApur", "indGuia", "tpAmb", "procEmi", "verProc" })
public class TIdeEventoFolhaSemRetificacao {

    protected byte indApuracao;

    @XmlElement(required = true)
    protected String perApur;

    protected Byte indGuia;

    protected byte tpAmb;

    protected byte procEmi;

    @XmlElement(required = true)
    protected String verProc;

    public byte getIndApuracao() {
        return indApuracao;
    }

    /**
     * Define o valor da propriedade indApuracao.
     */
    public void setIndApuracao(byte value) {
        this.indApuracao = value;
    }

    public String getPerApur() {
        return perApur;
    }

    /**
     * Define o valor da propriedade perApur.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     */
    public void setPerApur(String value) {
        this.perApur = value;
    }

    public Byte getIndGuia() {
        return indGuia;
    }

    /**
     * Define o valor da propriedade indGuia.
     *
     * @param value
     *     allowed object is
     *     {@link Byte }
     */

    public byte getTpAmb() {
        return tpAmb;
    }

    /**
     * Define o valor da propriedade tpAmb.
     */
    public void setTpAmb(byte value) {
        this.tpAmb = value;
    }

    public byte getProcEmi() {
        return procEmi;
    }

    /**
     * Define o valor da propriedade procEmi.
     */
    public void setProcEmi(byte value) {
        this.procEmi = value;
    }

    public String getVerProc() {
        return verProc;
    }

    /**
     * Define o valor da propriedade verProc.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     */
    public void setVerProc(String value) {
        this.verProc = value;
    }
}


public ContactDataUpdater getProContactUpdater() {
        return proContactUpdater;
    }

package org.bonitasoft.engine.identity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * represents a helper for updating a {@link User}. Chaining is possible with this updator to ease the {@link User}
 * update.
 * <br>
 * For instance, new UserUpdater.setUsername("john.doe").setFirstname("John").setLastname("Doe");
 *
 * @author Matthieu Chaffotte
 * @author Celine Souchet
 * @see User
 * @since 6.0.0
 */
public class UserUpdater implements Serializable {

    private static final long serialVersionUID = 4565052647320534796L;

    /**
     * represent the available {@link User} fields
     */
    public enum UserField {

        USER_NAME,
        PASSWORD,
        FIRST_NAME,
        LAST_NAME,
        @Deprecated
        ICON_NAME,
        @Deprecated
        ICON_PATH,
        TITLE,
        JOB_TITLE,
        MANAGER_ID,
        ENABLED,
        ICON_FILENAME,
        ICON_CONTENT
    }

    private final Map<UserField, Serializable> fields;

    private ContactDataUpdater persoContactUpdater;

    private ContactDataUpdater proContactUpdater;

    public UserUpdater() {
        fields = new HashMap<>(5);
    }

    /**
     * @param name the user's username to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setUserName(final String name) {
        fields.put(UserField.USER_NAME, name);
        return this;
    }

    /**
     * @param password the user's password to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setPassword(final String password) {
        fields.put(UserField.PASSWORD, password);
        return this;
    }

    /**
     * @param firstName the user's firstname to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setFirstName(final String firstName) {
        fields.put(UserField.FIRST_NAME, firstName);
        return this;
    }

    /**
     * @param lastName the user's lastname to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setLastName(final String lastName) {
        fields.put(UserField.LAST_NAME, lastName);
        return this;
    }

    /**
     * @param iconName the user's icon name to update
     * @return the current {@link UserUpdater} for chaining purpose
     * @deprecated since 7.3.0 use #setIcon
     */
    @Deprecated
    public UserUpdater setIconName(final String iconName) {
        return this;
    }

    /**
     * @param managerId the user's manager id to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setManagerId(final long managerId) {
        fields.put(UserField.MANAGER_ID, managerId);
        return this;
    }

    /**
     * @param iconPath the user's icon path to update
     * @return the current {@link UserUpdater} for chaining purpose
     * @deprecated since 7.3.0 use #setIcon
     */
    @Deprecated
    public UserUpdater setIconPath(final String iconPath) {
        return this;
    }

    /**
     * @param title the user's title to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setTitle(final String title) {
        fields.put(UserField.TITLE, title);
        return this;
    }

    /**
     * @param jobTitle the user's job title to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setJobTitle(final String jobTitle) {
        fields.put(UserField.JOB_TITLE, jobTitle);
        return this;
    }

    /**
     * @param enabled allow to know if the current user is enabled inside organization
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setEnabled(final boolean enabled) {
        fields.put(UserField.ENABLED, enabled);
        return this;
    }

    /**
     * @return the current user information to udpate
     */
    public Map<UserField, Serializable> getFields() {
        return fields;
    }

    /**
     * @param persoContactUpdater the user's personal contact information to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setPersonalContactData(final ContactDataUpdater persoContactUpdater) {
        this.persoContactUpdater = persoContactUpdater;
        return this;
    }

    /**
     * @param proContactUpdater the user's professional contact information to update
     * @return the current {@link UserUpdater} for chaining purpose
     */
    public UserUpdater setProfessionalContactData(final ContactDataUpdater proContactUpdater) {
        this.proContactUpdater = proContactUpdater;
        return this;
    }

    /**
     * @return the user's personal contact updater object
     */
    public ContactDataUpdater getPersoContactUpdater() {
        return persoContactUpdater;
    }

    /**
     * @return the professional contact updater object
     */

    /**
     * Has this updater at least one field to update (directly or in its personal / professional contact data)?
     *
     * @return true if there is at least one field to update
     */
    public boolean hasFields() {
        return !getFields().isEmpty() || getPersoContactUpdater() != null && getPersoContactUpdater().hasFields() || getProContactUpdater() != null && getProContactUpdater().hasFields();
    }

    public UserUpdater setIcon(String filename, byte[] content) {
        fields.put(UserField.ICON_FILENAME, filename);
        fields.put(UserField.ICON_CONTENT, content);
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        UserUpdater that = (UserUpdater) o;
        return Objects.equals(fields, that.fields) && Objects.equals(persoContactUpdater, that.persoContactUpdater) && Objects.equals(proContactUpdater, that.proContactUpdater);
    }

    @Override
    public int hashCode() {
        return Objects.hash(fields, persoContactUpdater, proContactUpdater);
    }

    @Override
    public String toString() {
        return "UserUpdater{" + "fields=" + fields + ", persoContactUpdater=" + persoContactUpdater + ", proContactUpdater=" + proContactUpdater + '}';
    }
}


public NamenodeRole getRole() {
        return role;
    }

package org.apache.hadoop.hdfs.server.protocol;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableFactories;
import org.apache.hadoop.io.WritableFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hdfs.server.common.Storage;
import org.apache.hadoop.hdfs.server.common.StorageInfo;
import org.apache.hadoop.hdfs.server.common.HdfsConstants.NamenodeRole;

/**
 * Information sent by a subordinate name-node to the active name-node
 * during the registration process.
 */
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class NamenodeRegistration extends StorageInfo implements NodeRegistration {

    // RPC address of the node
    String rpcAddress;

    // HTTP address of the node
    String httpAddress;

    // node role
    NamenodeRole role;

    // the age of the image
    long checkpointTime = -1L;

    public NamenodeRegistration() {
        super();
    }

    public NamenodeRegistration(String address, String httpAddress, StorageInfo storageInfo, NamenodeRole role, long checkpointTime) {
        super();
        this.rpcAddress = address;
        this.httpAddress = httpAddress;
        this.setStorageInfo(storageInfo);
        this.role = role;
        this.checkpointTime = checkpointTime;
    }

    // NodeRegistration
    @Override
    public String getAddress() {
        return rpcAddress;
    }

    // NodeRegistration
    @Override
    public String getRegistrationID() {
        return Storage.getRegistrationID(this);
    }

    // NodeRegistration
    @Override
    public int getVersion() {
        return super.getLayoutVersion();
    }

    // NodeRegistration
    @Override
    public String toString() {
        return getClass().getSimpleName() + "(" + rpcAddress + ", role=" + getRole() + ")";
    }

    /**
     * Get name-node role.
     */

    public boolean isRole(NamenodeRole that) {
        return role.equals(that);
    }

    /**
     * Get the age of the image.
     */
    public long getCheckpointTime() {
        return checkpointTime;
    }

    // Writable
    static {
        WritableFactories.setFactory(NamenodeRegistration.class, new WritableFactory() {

            public Writable newInstance() {
                return new NamenodeRegistration();
            }
        });
    }

    // Writable
    @Override
    public void write(DataOutput out) throws IOException {
        Text.writeString(out, rpcAddress);
        Text.writeString(out, httpAddress);
        Text.writeString(out, role.name());
        super.write(out);
        out.writeLong(checkpointTime);
    }

    // Writable
    @Override
    public void readFields(DataInput in) throws IOException {
        rpcAddress = Text.readString(in);
        httpAddress = Text.readString(in);
        role = NamenodeRole.valueOf(Text.readString(in));
        super.readFields(in);
        checkpointTime = in.readLong();
    }
}


for (int i = 0; i < response.length; i++) {
                    namee.add(response[i]);
                    namess.put(u, response[i]);
                }

package me.woder.bot;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.gson.Gson;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import me.woder.json.UUIDResponse;
import me.woder.world.World;

public class EntityTracker {

    Client c;

    ArrayList<Entity> entities;

    HashBiMap<UUID, String> names = HashBiMap.create();

    Multimap<UUID, UUIDResponse> namess = HashMultimap.create();

    public EntityTracker(Client c) {
        this.c = c;
        entities = new ArrayList<Entity>();
    }

    public void addEntity(int eid, World world, double x, double y, double z, int type, byte pitch, byte headpitch, byte yaw, int vx, int vy, int vz) {
        if (findEntityId(eid) == null) {
            entities.add(new Entity(c, eid, world, x, y, z, type, pitch, headpitch, yaw, vx, vy, vz));
        }
    }

    public void addPlayer(int eid, World world, double x, double y, double z, byte pitch, byte yaw, short current, String name, UUID uuid) {
        if (findEntityId(eid) == null) {
            entities.add(new Player(c, eid, name, uuid, x, y, z, yaw, pitch, current));
        }
    }

    public void delEntity(int eid) {
        Entity e = findEntityId(eid);
        if (e != null) {
            e.destroyRadar();
            entities.remove(e);
        }
    }

    public void delAll() {
        for (Entity e : entities) {
            if (e != null) {
                e.destroyRadar();
            }
        }
        entities.clear();
        c.gui.pradar.repaint();
    }

    public Player findPlayer(String name) {
        Player p = null;
        for (Entity s : entities) {
            if (s.getEntity() instanceof Player) {
                Player a = (Player) s;
                if (a.getName().equalsIgnoreCase(name)) {
                    p = a;
                    break;
                }
            }
        }
        return p;
    }

    public Entity findEntityId(int id) {
        for (Entity e : entities) {
            if (e.getEntityId() == id) {
                return e;
            }
        }
        return null;
    }

    public String getNameUUID(UUID u) {
        String name = "";
        if (names.containsKey(u)) {
            name = names.get(u);
        } else {
            String result = c.sendGetRequest("http://example.com" + u.toString().replace("-", "") + "/names");
            Gson gson = new Gson();
            UUIDResponse[] response = gson.fromJson(result, UUIDResponse[].class);
            if (response != null) {
                // this null check is super important because some servers send rubbish rather than player names
                String o = response[response.length - 1].getName();
                name = o;
                names.put(u, o);
            }
        }
        return name;
    }

    // Please note that we should probably make this cache last only like 5 minutes max incase changes are made
    public List<UUIDResponse> getNamesUUID(UUID u) {
        Collection<UUIDResponse> namee = new ArrayList<UUIDResponse>();
        if (namess.containsKey(u)) {
            namee = namess.get(u);
        } else {
            String result = c.sendGetRequest("https://api.mojang.com/user/profiles/" + u.toString().replace("-", "") + "/names");
            Gson gson = new Gson();
            UUIDResponse[] response = gson.fromJson(result, UUIDResponse[].class);
            if (response != null) {
                // this null check is super important because some servers send rubbish rather than player names

            }
        }
        List<UUIDResponse> list = new ArrayList<UUIDResponse>(namee);
        return list;
    }

    public UUID getUUIDName(String name) {
        BiMap<String, UUID> invmap = names.inverse();
        UUID u = null;
        if (invmap.containsKey(name)) {
            u = invmap.get(name);
        } else {
            String result = c.sendGetRequest("http://example.com" + name);
            JSON jsonr = JSONSerializer.toJSON(result);
            if (!jsonr.isArray()) {
                JSONObject js = (JSONObject) jsonr;
                u = new UUID(new BigInteger(js.getString("id").substring(0, 16), 16).longValue(), new BigInteger(js.getString("id").substring(16), 16).longValue());
                names.put(u, name);
            }
        }
        return u;
    }
}


public final String toString() {
        return name;
    }

package org.jnode.apps.jpartition.commands.framework;

/**
 * Status for a command.
 * @author Fabien DUMINY (example@nnthink.com)
 */
public enum CommandStatus {

    /**
     * The command is not running.
     */
    NOT_RUNNING("not running"),
    /**
     * The command is running.
     */
    RUNNING("running"),
    /**
     * The command has run and finished with success.
     */
    SUCCESS("success"),
    /**
     * The command has run and failed.
     */
    FAILED("failed");

    /**
     * printable name of the status.
     */
    private final String name;

    private CommandStatus(String name) {
        this.name = name;
    }

    /**
     * Get a printable representation of the command.
     * @return printable representation of the command.
     */


public void performDefaults() {
        super.performDefaults();
        consoleOutputCheckBox.setSelection(getPreferenceStore().getDefaultBoolean(TexlipseProperties.BUILDER_CONSOLE_OUTPUT));
        auxParserCheckBox.setSelection(getPreferenceStore().getDefaultBoolean(TexlipseProperties.BUILDER_PARSE_AUX_FILES));
    }

package net.sourceforge.texlipse.properties;

import java.io.File;
import net.sourceforge.texlipse.TexlipsePlugin;
import net.sourceforge.texlipse.builder.BuilderRegistry;
import net.sourceforge.texlipse.builder.ProgramRunner;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;

/**
 * Builder preferences.
 *
 * @author Kimmo Karlsson
 */
public class BuilderSettingsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {

    // list of builders to configure
    private List builderList;

    // checkbox for enabling console output
    private Button consoleOutputCheckBox;

    // checkbox for enabling console output
    private Button auxParserCheckBox;

    // field for browsing to tex distribution install dir
    private Text texDirField;

    // last path opened with texDirField
    protected File lastPath;

    // button that opens an editor dialog
    private Button editButton;

    public BuilderSettingsPreferencePage() {
        super();
        setPreferenceStore(TexlipsePlugin.getDefault().getPreferenceStore());
        lastPath = new File(resolveTexDir());
    }

    /**
     * @return the supposed directory of the tex distribution binaries
     */
    private String resolveTexDir() {
        ProgramRunner runner = BuilderRegistry.getRunner(0);
        if (runner == null) {
            return File.separator;
        }
        String dir = runner.getProgramPath();
        if (dir == null || dir.length() == 0) {
            return File.separator;
        }
        int index = dir.lastIndexOf(File.separatorChar);
        if (index < 0) {
            return dir;
        }
        return dir.substring(0, index);
    }

    /**
     * Creates the page components.
     */
    protected Control createContents(Composite parent) {
        Composite contents = new Composite(parent, SWT.NULL);
        GridLayout gl = new GridLayout();
        gl.numColumns = 2;
        contents.setLayout(gl);
        addBuilderList(contents);
        TexlipsePreferencePage.addSpacer(2, false, contents);
        addTexInstallDir(contents);
        TexlipsePreferencePage.addSpacer(2, false, contents);
        addConsoleCheckBox(contents);
        addAuxParserCheckBox(contents);
        return contents;
    }

    /**
     * @param contents parent component
     */
    private void addTexInstallDir(Composite contents) {
        Composite parent = new Composite(contents, SWT.NULL);
        GridLayout layout = new GridLayout();
        layout.numColumns = 3;
        parent.setLayout(layout);
        GridData pgd = new GridData(GridData.FILL_HORIZONTAL);
        pgd.horizontalSpan = 2;
        parent.setLayoutData(pgd);
        TexlipsePreferencePage.addLabelField(3, TexlipsePlugin.getResourceString("preferenceBuilderTexDirDescription"), parent);
        Label label = new Label(parent, SWT.LEFT);
        label.setText(TexlipsePlugin.getResourceString("preferenceBuilderTexDirLabel"));
        label.setLayoutData(new GridData());
        texDirField = new Text(parent, SWT.SINGLE | SWT.BORDER);
        texDirField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        texDirField.setText("");
        PlatformUI.getWorkbench().getHelpSystem().setHelp(texDirField, TexlipseHelpIds.BUILDER_TEX_DIR);
        Button button = new Button(parent, SWT.PUSH);
        button.setText(JFaceResources.getString("openBrowse"));
        button.setLayoutData(new GridData());
        button.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                DirectoryDialog dialog = new DirectoryDialog(getShell());
                if (lastPath != null) {
                    if (lastPath.exists())
                        dialog.setFilterPath(lastPath.getAbsolutePath());
                }
                String dir = dialog.open();
                if (dir != null) {
                    lastPath = new File(dir.trim());
                    if (lastPath.exists()) {
                        texDirField.setText(lastPath.getAbsolutePath());
                    } else {
                        lastPath = null;
                    }
                }
            }
        });
    }

    /**
     * Add list of builders with an edit button.
     *
     * @param contents parent component
     */
    private void addBuilderList(Composite contents) {
        Composite leftPart = new Composite(contents, SWT.NULL);
        leftPart.setLayout(new GridLayout());
        leftPart.setLayoutData(new GridData(GridData.FILL_BOTH));
        Label label = new Label(leftPart, SWT.LEFT);
        label.setText(TexlipsePlugin.getResourceString("preferenceBuilderListLabel"));
        label.setLayoutData(new GridData());
        builderList = new List(leftPart, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
        builderList.setItems(getBuilderItems());
        builderList.setLayoutData(new GridData(GridData.FILL_BOTH));
        builderList.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                int index = builderList.getSelectionIndex();
                editButton.setEnabled(index >= 0);
            }
        });
        PlatformUI.getWorkbench().getHelpSystem().setHelp(builderList, TexlipseHelpIds.BUILDER_LIST);
        Composite rightPart = new Composite(contents, SWT.NULL);
        rightPart.setLayout(new GridLayout());
        rightPart.setLayoutData(new GridData(GridData.FILL_BOTH));
        Label empty = new Label(rightPart, SWT.LEFT);
        empty.setLayoutData(new GridData());
        editButton = new Button(rightPart, SWT.PUSH);
        editButton.setEnabled(false);
        editButton.setText(TexlipsePlugin.getResourceString("openEdit"));
        editButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        editButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                int index = builderList.getSelectionIndex();
                if (index >= 0) {
                    openEditorDialog(index);
                }
            }
        });
        Label filler = new Label(rightPart, SWT.LEFT);
        filler.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    }

    /**
     * Add "output to console" -checkbox.
     *
     * @param contents parent component
     */
    private void addConsoleCheckBox(Composite contents) {
        Composite checkField = new Composite(contents, SWT.NULL);
        GridData checkData = new GridData(GridData.FILL_HORIZONTAL);
        checkData.horizontalSpan = 2;
        checkField.setLayoutData(checkData);
        GridLayout checkLay = new GridLayout();
        checkLay.numColumns = 2;
        checkField.setLayout(checkLay);
        consoleOutputCheckBox = new Button(checkField, SWT.CHECK);
        consoleOutputCheckBox.setLayoutData(new GridData());
        consoleOutputCheckBox.setText(TexlipsePlugin.getResourceString("preferenceBuilderConsoleOutput"));
        consoleOutputCheckBox.setSelection(getPreferenceStore().getBoolean(TexlipseProperties.BUILDER_CONSOLE_OUTPUT));
        // checkboxes don't show their help ids (at least on linux)
        PlatformUI.getWorkbench().getHelpSystem().setHelp(consoleOutputCheckBox, TexlipseHelpIds.BUILDER_CONSOLE);
    }

    /**
     * Add "Parse .aux files" -checkbox.
     *
     * @param contents parent component
     */
    private void addAuxParserCheckBox(Composite contents) {
        Composite checkField = new Composite(contents, SWT.NULL);
        GridData checkData = new GridData(GridData.FILL_HORIZONTAL);
        checkData.horizontalSpan = 2;
        checkField.setLayoutData(checkData);
        GridLayout checkLay = new GridLayout();
        checkLay.numColumns = 2;
        checkField.setLayout(checkLay);
        auxParserCheckBox = new Button(checkField, SWT.CHECK);
        auxParserCheckBox.setLayoutData(new GridData());
        auxParserCheckBox.setText(TexlipsePlugin.getResourceString("preferenceBuilderAuxParser"));
        auxParserCheckBox.setSelection(getPreferenceStore().getBoolean(TexlipseProperties.BUILDER_PARSE_AUX_FILES));
    }

    /**
     * Called when ok-button (or apply-button) is pressed. Saves all the field
     * editor values to preferences.
     *
     * @return true
     */
    public boolean performOk() {
        boolean ok = super.performOk();
        getPreferenceStore().setValue(TexlipseProperties.BUILDER_CONSOLE_OUTPUT, consoleOutputCheckBox.getSelection());
        getPreferenceStore().setValue(TexlipseProperties.BUILDER_PARSE_AUX_FILES, auxParserCheckBox.getSelection());
        changeTexDistribution();
        texDirField.setText("");
        builderList.setItems(getBuilderItems());
        return ok;
    }

    /**
     * Called when defaults-button is pressed. Sets all field values to defaults.
     * Currently does nothing to builder paths.
     */

    /**
     * Change the tex distribution of all program runners.
     */
    private void changeTexDistribution() {
        String texDir = texDirField.getText();
        if (texDir != null && texDir.length() > 0) {
            File dir = new File(texDir);
            if (dir != null && dir.exists() && dir.isDirectory()) {
                int size = BuilderRegistry.getNumberOfRunners();
                for (int i = 0; i < size; i++) {
                    ProgramRunner prog = BuilderRegistry.getRunner(i);
                    File file = new File(dir, prog.getProgramName());
                    if (file != null && file.exists() && file.isFile()) {
                        prog.setProgramPath(file.getAbsolutePath());
                    }
                }
            }
        }
    }

    /**
     * @return list of labels for configurable builders
     */
    private String[] getBuilderItems() {
        int number = BuilderRegistry.getNumberOfRunners();
        String[] array = new String[number];
        for (int i = 0; i < number; i++) {
            array[i] = getRunnerLabel(i);
        }
        return array;
    }

    /**
     * @param runner index
     * @return label for configurable builder
     */
    private String getRunnerLabel(int i) {
        ProgramRunner runner = BuilderRegistry.getRunner(i);
        return runner.getDescription() + "        (" + runner.getProgramPath() + ')';
    }

    /**
     * Opens the BuilderConfigDialog.
     *
     * @param index index of the configurable builder
     */
    private void openEditorDialog(int index) {
        BuilderConfigDialog dialog = new BuilderConfigDialog(getShell(), BuilderRegistry.getRunner(index));
        int code = dialog.open();
        if (code == BuilderConfigDialog.OK) {
            builderList.setItem(index, getRunnerLabel(index));
        }
    }

    /**
     * Page initialization. Does nothing.
     */
    public void init(IWorkbench workbench) {
    }
}


for (int i = 0; i < size; i++) {
                    ProgramRunner prog = BuilderRegistry.getRunner(i);
                    File file = new File(dir, prog.getProgramName());
                    if (file != null && file.exists() && file.isFile()) {
                        prog.setProgramPath(file.getAbsolutePath());
                    }
                }

package net.sourceforge.texlipse.properties;

import java.io.File;
import net.sourceforge.texlipse.TexlipsePlugin;
import net.sourceforge.texlipse.builder.BuilderRegistry;
import net.sourceforge.texlipse.builder.ProgramRunner;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;

/**
 * Builder preferences.
 *
 * @author Kimmo Karlsson
 */
public class BuilderSettingsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {

    // list of builders to configure
    private List builderList;

    // checkbox for enabling console output
    private Button consoleOutputCheckBox;

    // checkbox for enabling console output
    private Button auxParserCheckBox;

    // field for browsing to tex distribution install dir
    private Text texDirField;

    // last path opened with texDirField
    protected File lastPath;

    // button that opens an editor dialog
    private Button editButton;

    public BuilderSettingsPreferencePage() {
        super();
        setPreferenceStore(TexlipsePlugin.getDefault().getPreferenceStore());
        lastPath = new File(resolveTexDir());
    }

    /**
     * @return the supposed directory of the tex distribution binaries
     */
    private String resolveTexDir() {
        ProgramRunner runner = BuilderRegistry.getRunner(0);
        if (runner == null) {
            return File.separator;
        }
        String dir = runner.getProgramPath();
        if (dir == null || dir.length() == 0) {
            return File.separator;
        }
        int index = dir.lastIndexOf(File.separatorChar);
        if (index < 0) {
            return dir;
        }
        return dir.substring(0, index);
    }

    /**
     * Creates the page components.
     */
    protected Control createContents(Composite parent) {
        Composite contents = new Composite(parent, SWT.NULL);
        GridLayout gl = new GridLayout();
        gl.numColumns = 2;
        contents.setLayout(gl);
        addBuilderList(contents);
        TexlipsePreferencePage.addSpacer(2, false, contents);
        addTexInstallDir(contents);
        TexlipsePreferencePage.addSpacer(2, false, contents);
        addConsoleCheckBox(contents);
        addAuxParserCheckBox(contents);
        return contents;
    }

    /**
     * @param contents parent component
     */
    private void addTexInstallDir(Composite contents) {
        Composite parent = new Composite(contents, SWT.NULL);
        GridLayout layout = new GridLayout();
        layout.numColumns = 3;
        parent.setLayout(layout);
        GridData pgd = new GridData(GridData.FILL_HORIZONTAL);
        pgd.horizontalSpan = 2;
        parent.setLayoutData(pgd);
        TexlipsePreferencePage.addLabelField(3, TexlipsePlugin.getResourceString("preferenceBuilderTexDirDescription"), parent);
        Label label = new Label(parent, SWT.LEFT);
        label.setText(TexlipsePlugin.getResourceString("preferenceBuilderTexDirLabel"));
        label.setLayoutData(new GridData());
        texDirField = new Text(parent, SWT.SINGLE | SWT.BORDER);
        texDirField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        texDirField.setText("");
        PlatformUI.getWorkbench().getHelpSystem().setHelp(texDirField, TexlipseHelpIds.BUILDER_TEX_DIR);
        Button button = new Button(parent, SWT.PUSH);
        button.setText(JFaceResources.getString("openBrowse"));
        button.setLayoutData(new GridData());
        button.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                DirectoryDialog dialog = new DirectoryDialog(getShell());
                if (lastPath != null) {
                    if (lastPath.exists())
                        dialog.setFilterPath(lastPath.getAbsolutePath());
                }
                String dir = dialog.open();
                if (dir != null) {
                    lastPath = new File(dir.trim());
                    if (lastPath.exists()) {
                        texDirField.setText(lastPath.getAbsolutePath());
                    } else {
                        lastPath = null;
                    }
                }
            }
        });
    }

    /**
     * Add list of builders with an edit button.
     *
     * @param contents parent component
     */
    private void addBuilderList(Composite contents) {
        Composite leftPart = new Composite(contents, SWT.NULL);
        leftPart.setLayout(new GridLayout());
        leftPart.setLayoutData(new GridData(GridData.FILL_BOTH));
        Label label = new Label(leftPart, SWT.LEFT);
        label.setText(TexlipsePlugin.getResourceString("preferenceBuilderListLabel"));
        label.setLayoutData(new GridData());
        builderList = new List(leftPart, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
        builderList.setItems(getBuilderItems());
        builderList.setLayoutData(new GridData(GridData.FILL_BOTH));
        builderList.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                int index = builderList.getSelectionIndex();
                editButton.setEnabled(index >= 0);
            }
        });
        PlatformUI.getWorkbench().getHelpSystem().setHelp(builderList, TexlipseHelpIds.BUILDER_LIST);
        Composite rightPart = new Composite(contents, SWT.NULL);
        rightPart.setLayout(new GridLayout());
        rightPart.setLayoutData(new GridData(GridData.FILL_BOTH));
        Label empty = new Label(rightPart, SWT.LEFT);
        empty.setLayoutData(new GridData());
        editButton = new Button(rightPart, SWT.PUSH);
        editButton.setEnabled(false);
        editButton.setText(TexlipsePlugin.getResourceString("openEdit"));
        editButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        editButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                int index = builderList.getSelectionIndex();
                if (index >= 0) {
                    openEditorDialog(index);
                }
            }
        });
        Label filler = new Label(rightPart, SWT.LEFT);
        filler.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    }

    /**
     * Add "output to console" -checkbox.
     *
     * @param contents parent component
     */
    private void addConsoleCheckBox(Composite contents) {
        Composite checkField = new Composite(contents, SWT.NULL);
        GridData checkData = new GridData(GridData.FILL_HORIZONTAL);
        checkData.horizontalSpan = 2;
        checkField.setLayoutData(checkData);
        GridLayout checkLay = new GridLayout();
        checkLay.numColumns = 2;
        checkField.setLayout(checkLay);
        consoleOutputCheckBox = new Button(checkField, SWT.CHECK);
        consoleOutputCheckBox.setLayoutData(new GridData());
        consoleOutputCheckBox.setText(TexlipsePlugin.getResourceString("preferenceBuilderConsoleOutput"));
        consoleOutputCheckBox.setSelection(getPreferenceStore().getBoolean(TexlipseProperties.BUILDER_CONSOLE_OUTPUT));
        // checkboxes don't show their help ids (at least on linux)
        PlatformUI.getWorkbench().getHelpSystem().setHelp(consoleOutputCheckBox, TexlipseHelpIds.BUILDER_CONSOLE);
    }

    /**
     * Add "Parse .aux files" -checkbox.
     *
     * @param contents parent component
     */
    private void addAuxParserCheckBox(Composite contents) {
        Composite checkField = new Composite(contents, SWT.NULL);
        GridData checkData = new GridData(GridData.FILL_HORIZONTAL);
        checkData.horizontalSpan = 2;
        checkField.setLayoutData(checkData);
        GridLayout checkLay = new GridLayout();
        checkLay.numColumns = 2;
        checkField.setLayout(checkLay);
        auxParserCheckBox = new Button(checkField, SWT.CHECK);
        auxParserCheckBox.setLayoutData(new GridData());
        auxParserCheckBox.setText(TexlipsePlugin.getResourceString("preferenceBuilderAuxParser"));
        auxParserCheckBox.setSelection(getPreferenceStore().getBoolean(TexlipseProperties.BUILDER_PARSE_AUX_FILES));
    }

    /**
     * Called when ok-button (or apply-button) is pressed. Saves all the field
     * editor values to preferences.
     *
     * @return true
     */
    public boolean performOk() {
        boolean ok = super.performOk();
        getPreferenceStore().setValue(TexlipseProperties.BUILDER_CONSOLE_OUTPUT, consoleOutputCheckBox.getSelection());
        getPreferenceStore().setValue(TexlipseProperties.BUILDER_PARSE_AUX_FILES, auxParserCheckBox.getSelection());
        changeTexDistribution();
        texDirField.setText("");
        builderList.setItems(getBuilderItems());
        return ok;
    }

    /**
     * Called when defaults-button is pressed. Sets all field values to defaults.
     * Currently does nothing to builder paths.
     */
    public void performDefaults() {
        super.performDefaults();
        consoleOutputCheckBox.setSelection(getPreferenceStore().getDefaultBoolean(TexlipseProperties.BUILDER_CONSOLE_OUTPUT));
        auxParserCheckBox.setSelection(getPreferenceStore().getDefaultBoolean(TexlipseProperties.BUILDER_PARSE_AUX_FILES));
    }

    /**
     * Change the tex distribution of all program runners.
     */
    private void changeTexDistribution() {
        String texDir = texDirField.getText();
        if (texDir != null && texDir.length() > 0) {
            File dir = new File(texDir);
            if (dir != null && dir.exists() && dir.isDirectory()) {
                int size = BuilderRegistry.getNumberOfRunners();

            }
        }
    }

    /**
     * @return list of labels for configurable builders
     */
    private String[] getBuilderItems() {
        int number = BuilderRegistry.getNumberOfRunners();
        String[] array = new String[number];
        for (int i = 0; i < number; i++) {
            array[i] = getRunnerLabel(i);
        }
        return array;
    }

    /**
     * @param runner index
     * @return label for configurable builder
     */
    private String getRunnerLabel(int i) {
        ProgramRunner runner = BuilderRegistry.getRunner(i);
        return runner.getDescription() + "        (" + runner.getProgramPath() + ')';
    }

    /**
     * Opens the BuilderConfigDialog.
     *
     * @param index index of the configurable builder
     */
    private void openEditorDialog(int index) {
        BuilderConfigDialog dialog = new BuilderConfigDialog(getShell(), BuilderRegistry.getRunner(index));
        int code = dialog.open();
        if (code == BuilderConfigDialog.OK) {
            builderList.setItem(index, getRunnerLabel(index));
        }
    }

    /**
     * Page initialization. Does nothing.
     */
    public void init(IWorkbench workbench) {
    }
}


private static TupleSummaryData sumUp(Schema schema, Tuple t) throws ExecException {
        TupleSummaryData summaryData = new TupleSummaryData();
        DataBag bag = (DataBag) t.get(0);
        for (Tuple tuple : bag) {
            summaryData.addTuple(schema, tuple);
        }
        return summaryData;
    }

package org.apache.parquet.pig.summary;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.pig.Algebraic;
import org.apache.pig.EvalFunc;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
import org.apache.pig.impl.logicalLayer.schema.Schema;

/**
 * computes a summary of the input to a json string
 */
public class Summary extends EvalFunc<String> implements Algebraic {

    private static final TupleFactory TF = TupleFactory.getInstance();

    public static class Initial extends EvalFunc<Tuple> {

        @Override
        public Tuple exec(Tuple t) throws IOException {
            return new JSONTuple(sumUp(getInputSchema(), t));
        }
    }

    public static class Intermediate extends EvalFunc<Tuple> {

        @Override
        public Tuple exec(Tuple t) throws IOException {
            return new JSONTuple(merge(t));
        }
    }

    public static class Final extends EvalFunc<String> {

        @Override
        public String exec(Tuple t) throws IOException {
            return SummaryData.toPrettyJSON(merge(t));
        }
    }

    private static final class JSONTuple implements Tuple {

        private static final long serialVersionUID = 1L;

        private TupleSummaryData data;

        public JSONTuple(TupleSummaryData data) {
            this.data = data;
        }

        @Override
        public void readFields(DataInput dataInput) throws IOException {
            throw new UnsupportedOperationException();
        }

        @Override
        public void write(DataOutput dataOutput) throws IOException {
            Tuple t = TF.newTuple(json());
            t.write(dataOutput);
        }

        @Override
        public int compareTo(Object o) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void append(Object o) {
            throw new UnsupportedOperationException();
        }

        @Override
        public Object get(int i) throws ExecException {
            if (i == 0) {
                return json();
            }
            throw new ExecException();
        }

        private String json() {
            return SummaryData.toJSON(data);
        }

        @Override
        public List<Object> getAll() {
            return new ArrayList<Object>(Arrays.asList(json()));
        }

        @Override
        public long getMemorySize() {
            // I don't know. Not too big and we're not going to have many
            return 100;
        }

        @Override
        public byte getType(int i) throws ExecException {
            if (i == 0) {
                return DataType.CHARARRAY;
            }
            throw new ExecException("size is 1");
        }

        @Override
        public boolean isNull(int i) throws ExecException {
            if (i == 0) {
                return false;
            }
            throw new ExecException("size is 1");
        }

        @Override
        public void reference(Tuple t) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void set(int i, Object o) throws ExecException {
            throw new UnsupportedOperationException();
        }

        @Override
        public int size() {
            return 1;
        }

        @Override
        public String toDelimitedString(String delim) throws ExecException {
            return json();
        }

        @Override
        public Iterator<Object> iterator() {
            return getAll().iterator();
        }
    }

    private static TupleSummaryData getData(Tuple tuple) throws ExecException {
        if (tuple instanceof JSONTuple) {
            return ((JSONTuple) tuple).data;
        } else {
            return SummaryData.fromJSON((String) tuple.get(0), TupleSummaryData.class);
        }
    }

    /**
     * the input tuple contains a bag of string representations of TupleSummaryData
     *
     * @param t
     * @return
     * @throws ExecException
     * @throws IOException
     */
    private static TupleSummaryData merge(Tuple t) throws IOException {
        TupleSummaryData summaryData = new TupleSummaryData();
        DataBag bag = (DataBag) t.get(0);
        for (Tuple tuple : bag) {
            summaryData.merge(getData(tuple));
        }
        return summaryData;
    }

    /**
     * The input tuple contains a bag of Tuples to sum up
     *
     * @param t
     * @return
     * @throws ExecException
     */

    @Override
    public String exec(Tuple t) throws IOException {
        return SummaryData.toPrettyJSON(sumUp(getInputSchema(), t));
    }

    @Override
    public String getInitial() {
        return Initial.class.getName();
    }

    @Override
    public String getIntermed() {
        return Intermediate.class.getName();
    }

    @Override
    public String getFinal() {
        return Final.class.getName();
    }
}


while (this.hasMoreEvents()) {
            allPages.addAll(getNextFrame());
        }

package com.heychinaski.historyhack.provider;

import java.util.ArrayList;
import java.util.List;
import com.heychinaski.historyhack.model.GeoEventPage;

public class AllJsonEventsProvider extends JsonInputGEPProvider {

    public AllJsonEventsProvider(String filename) {
        super(filename);
    }

    public List<GeoEventPage> getAllAsList() {
        List<GeoEventPage> allPages = new ArrayList<GeoEventPage>();


while (n != null) {
                if (n.getNodeType() == Node.ELEMENT_NODE) {
                    Element mtype = ((Element) n);
                    String type = n.getNodeName().toLowerCase();
                    if (!"web".equals(type)) {
                        String path = mtype.getTextContent().trim();
                        paths.add(path);
                    }
                }
                n = n.getNextSibling();
            }

/*
 *
 *
 * Contributors:
 *     bstefanescu
 *     jcarsique
 *     Kevin Leturc <example@nnthink.com>
 */
package org.nuxeo.runtime.deployment.preprocessor;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuxeo.common.utils.ZipUtils;
import org.nuxeo.launcher.config.ConfigurationException;
import org.nuxeo.launcher.config.ConfigurationGenerator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 * @author Bogdan Stefanescu
 */
public class PackZip {

    private static Log log = LogFactory.getLog(PackZip.class);

    public static final String ORDER_PREPROCESSING = "preprocessing";

    public static final String ORDER_PACKAGING = "packaging";

    protected File nuxeoEar;

    protected File deployerJar;

    protected File deployDir;

    protected File jbossLib;

    protected File dsFile;

    protected File target;

    public PackZip(File nuxeoEar, File target) {
        if (!nuxeoEar.isDirectory()) {
            throw new IllegalArgumentException("Invalid build - no exploded nuxeo.ear found at " + nuxeoEar.getAbsolutePath());
        }
        if (!target.isDirectory()) {
            throw new IllegalArgumentException("Invalid configuration - no target directory found at " + nuxeoEar.getAbsolutePath());
        }
        this.nuxeoEar = nuxeoEar;
        this.target = target;
        this.deployDir = nuxeoEar.getParentFile();
        this.jbossLib = new File(deployDir.getParentFile(), "lib");
        this.dsFile = new File(deployDir, "nuxeo-ds.xml");
        File deployers = new File(deployDir.getParentFile(), "deployers");
        String[] names = deployers.list();
        if (names == null) {
            throw new IllegalArgumentException("Invalid nuxeo.ear location - no nuxeo jboss deployer JAR found in deployers directory");
        }
        for (String name : names) {
            if (name.startsWith("nuxeo-jboss-deployer") && name.endsWith(".jar")) {
                deployerJar = new File(deployers, name);
            }
        }
        if (deployerJar == null) {
            throw new IllegalArgumentException("Invalid build - no nuxeo jboss deployer JAR found in deployers directory");
        }
    }

    protected void executePreprocessing() throws ConfigurationException, IOException {
        // configure from templates
        new ConfigurationGenerator().run();
        // run preprocessor
        runPreprocessor();
    }

    protected void executePackaging() throws IOException, SAXException, ParserConfigurationException {
        // move non ejb jars to nuxeo.ear/lib
        moveNonEjbsToLib(nuxeoEar);
        // replace nuxeo-structure.xml with nuxeo-structure-zip.xml
        replaceStructureFile();
        // move libs in jboss/lib to nuxeo.ear/lib
        moveJarsFromJbossLib();
        // move nuxeo jboss deployer to nuxeo.ear/lib
        FileUtils.moveFile(deployerJar, new File(nuxeoEar, "lib" + File.separator + deployerJar.getName()));
        // zip the ear into target directory
        ZipUtils.zip(nuxeoEar.listFiles(), new File(target, "nuxeo.ear"));
        // copy nuxeo-ds.xml to target dir
        FileUtils.copyFileToDirectory(dsFile, target);
    }

    public void execute(String order) throws ConfigurationException, IOException, ParserConfigurationException, SAXException {
        if (ORDER_PREPROCESSING.equals(order) || StringUtils.isBlank(order)) {
            executePreprocessing();
        }
        if (ORDER_PACKAGING.equals(order) || StringUtils.isBlank(order)) {
            executePackaging();
        }
        if (!(ORDER_PREPROCESSING.equals(order) || StringUtils.isBlank(order) || ORDER_PACKAGING.equals(order))) {
            fail("Order param should be " + ORDER_PREPROCESSING + " or " + ORDER_PACKAGING);
        }
    }

    protected void runPreprocessor() throws IOException {
        DeploymentPreprocessor.main(new String[] { nuxeoEar.getAbsolutePath() });
    }

    protected void replaceStructureFile() throws IOException {
        File oldf = new File(nuxeoEar, "META-INF" + File.separator + "nuxeo-structure.xml");
        File newf = new File(nuxeoEar, "META-INF" + File.separator + "nuxeo-structure-zip.xml");
        if (oldf.exists() && !FileUtils.deleteQuietly(oldf)) {
            log.warn("Cannot delete " + oldf.getName() + ", it may not replace it with the new file.");
        }
        FileUtils.moveFile(newf, oldf);
    }

    protected void moveJarsFromJbossLib() {
    }

    protected void moveNonEjbsToLib(File wd) throws ParserConfigurationException, SAXException, IOException {
        File file = new File(wd, "META-INF" + File.separator + "application.xml");
        if (!file.isFile()) {
            log.error("You should run this tool from a preprocessed nuxeo.ear folder");
        }
        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        FileInputStream in = new FileInputStream(file);
        Document doc = docBuilder.parse(in);
        Element root = doc.getDocumentElement();
        NodeList list = root.getElementsByTagName("module");
        Collection<String> paths = new ArrayList<>();
        for (int i = 0; i < list.getLength(); i++) {
            Element el = (Element) list.item(i);
            Node n = el.getFirstChild();

        }
        File ejbs = new File(wd, "tmp-ejbs");
        ejbs.mkdirs();
        for (String path : paths) {
            log.info("Move EAR module " + path + " to " + ejbs.getName());
            File f = new File(wd, path);
            if (f.getName().endsWith(".txt")) {
                continue;
            }
            FileUtils.moveToDirectory(f, ejbs, false);
        }
        File lib = new File(wd, "lib");
        File[] files = new File(wd, "bundles").listFiles();
        if (files != null) {
            for (File f : files) {
                if (f.getName().endsWith(".txt")) {
                    continue;
                }
                log.info("Move POJO bundle " + f.getName() + " to lib");
                FileUtils.moveToDirectory(f, lib, false);
            }
        }
        File bundles = new File(wd, "bundles");
        files = ejbs.listFiles();
        if (files != null) {
            for (File f : files) {
                if (f.getName().endsWith(".txt")) {
                    continue;
                }
                log.info("Move back EAR module " + f.getName() + " to bundles");
                FileUtils.moveToDirectory(f, bundles, false);
            }
        }
    }

    protected static void fail(String message) {
        log.error(message);
        System.exit(1);
    }

    public static void main(String[] args) throws IOException, ConfigurationException, ParserConfigurationException, SAXException {
        if (args.length < 2) {
            fail("Usage: PackZip nuxeo_ear_directory target_directory [order]");
        }
        String v = args[0];
        File ear = new File(v);
        if (!ear.isDirectory()) {
            fail("Invalid build - no exploded nuxeo.ear found at " + ear.getAbsolutePath());
        }
        v = args[1];
        File target = new File(v);
        ear = ear.getCanonicalFile();
        target = target.getCanonicalFile();
        if (target.exists()) {
            FileUtils.deleteDirectory(target);
        }
        target.mkdirs();
        if (!target.isDirectory()) {
            fail("Invalid target directory: " + v + ". Not a directory or directory could not be created");
        }
        log.info("Packing nuxeo.ear at " + ear.getAbsolutePath() + " into " + target.getAbsolutePath());
        PackZip pack = new PackZip(ear, target);
        if (args.length >= 3) {
            pack.execute(args[2]);
        } else {
            pack.execute(null);
        }
    }
}