text:
package nxt;

import nxt.NxtException.NotValidException;
import nxt.at.AT_Controller;
import nxt.at.AT_Exception;
import nxt.crypto.EncryptedData;
import nxt.util.Convert;
import nxt.util.Logger;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;

public interface Attachment extends Appendix {

    TransactionType getTransactionType();

    abstract static class AbstractAttachment extends AbstractAppendix implements Attachment {

        private AbstractAttachment(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
        }

        private AbstractAttachment(JSONObject attachmentData) {
            super(attachmentData);
        }

        private AbstractAttachment(int version) {
            super(version);
        }

        private AbstractAttachment() {}

        @Override
        final void validate(Transaction transaction) throws NxtException.ValidationException {
            getTransactionType().validateAttachment(transaction);
        }

        @Override
        final void apply(Transaction transaction, Account senderAccount, Account recipientAccount) {
            getTransactionType().apply(transaction, senderAccount, recipientAccount);
        }

    }

    abstract static class EmptyAttachment extends AbstractAttachment {

        private EmptyAttachment() {
            super(0);
        }

        @Override
        final int getMySize() {
            return 0;
        }

        @Override
        final void putMyBytes(ByteBuffer buffer) {
        }

        @Override
        final void putMyJSON(JSONObject json) {
        }

        @Override
        final boolean verifyVersion(byte transactionVersion) {
            return true;
        }

    }

    public final static EmptyAttachment ORDINARY_PAYMENT = new EmptyAttachment() {

        @Override
        String getAppendixName() {
            return "OrdinaryPayment";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Payment.ORDINARY;
        }

    };

    // the message payload is in the Appendix
    public final static EmptyAttachment ARBITRARY_MESSAGE = new EmptyAttachment() {

        @Override
        String getAppendixName() {
            return "ArbitraryMessage";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.ARBITRARY_MESSAGE;
        }

    };

    public static final EmptyAttachment AT_PAYMENT = new EmptyAttachment() {

		@Override
		public TransactionType getTransactionType() {
			return TransactionType.AutomatedTransactions.AT_PAYMENT;
		}

		@Override
		String getAppendixName() {
			return "AT Payment";
		}

	};

    public final static class MessagingAliasAssignment extends AbstractAttachment {

        private final String aliasName;
        private final String aliasURI;

        MessagingAliasAssignment(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            aliasName = Convert.readString(buffer, buffer.get(), Constants.MAX_ALIAS_LENGTH).trim();
            aliasURI = Convert.readString(buffer, buffer.getShort(), Constants.MAX_ALIAS_URI_LENGTH).trim();
        }

        MessagingAliasAssignment(JSONObject attachmentData) {
            super(attachmentData);
            aliasName = (Convert.nullToEmpty((String) attachmentData.get("alias"))).trim();
            aliasURI = (Convert.nullToEmpty((String) attachmentData.get("uri"))).trim();
        }

        public MessagingAliasAssignment(String aliasName, String aliasURI) {
            this.aliasName = aliasName.trim();
            this.aliasURI = aliasURI.trim();
        }

        @Override
        String getAppendixName() {
            return "AliasAssignment";
        }

        @Override
        int getMySize() {
            return 1 + Convert.toBytes(aliasName).length + 2 + Convert.toBytes(aliasURI).length;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] alias = Convert.toBytes(this.aliasName);
            byte[] uri = Convert.toBytes(this.aliasURI);
            buffer.put((byte)alias.length);
            buffer.put(alias);
            buffer.putShort((short) uri.length);
            buffer.put(uri);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("alias", aliasName);
            attachment.put("uri", aliasURI);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.ALIAS_ASSIGNMENT;
        }

        public String getAliasName() {
            return aliasName;
        }

        public String getAliasURI() {
            return aliasURI;
        }
    }

    public final static class MessagingAliasSell extends AbstractAttachment {

        private final String aliasName;
        private final long priceNQT;

        MessagingAliasSell(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.aliasName = Convert.readString(buffer, buffer.get(), Constants.MAX_ALIAS_LENGTH);
            this.priceNQT = buffer.getLong();
        }

        MessagingAliasSell(JSONObject attachmentData) {
            super(attachmentData);
            this.aliasName = Convert.nullToEmpty((String) attachmentData.get("alias"));
            this.priceNQT = Convert.parseLong(attachmentData.get("priceNQT"));
        }

        public MessagingAliasSell(String aliasName, long priceNQT) {
            this.aliasName = aliasName;
            this.priceNQT = priceNQT;
        }

        @Override
        String getAppendixName() {
            return "AliasSell";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.ALIAS_SELL;
        }

        @Override
        int getMySize() {
            return 1 + Convert.toBytes(aliasName).length + 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] aliasBytes = Convert.toBytes(aliasName);
            buffer.put((byte)aliasBytes.length);
            buffer.put(aliasBytes);
            buffer.putLong(priceNQT);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("alias", aliasName);
            attachment.put("priceNQT", priceNQT);
        }

        public String getAliasName(){
            return aliasName;
        }

        public long getPriceNQT(){
            return priceNQT;
        }
    }

    public final static class MessagingAliasBuy extends AbstractAttachment {

        private final String aliasName;

        MessagingAliasBuy(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.aliasName = Convert.readString(buffer, buffer.get(), Constants.MAX_ALIAS_LENGTH);
        }

        MessagingAliasBuy(JSONObject attachmentData) {
            super(attachmentData);
            this.aliasName = Convert.nullToEmpty((String) attachmentData.get("alias"));
        }

        public MessagingAliasBuy(String aliasName) {
            this.aliasName = aliasName;
        }

        @Override
        String getAppendixName() {
            return "AliasBuy";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.ALIAS_BUY;
        }

        @Override
        int getMySize() {
            return 1 + Convert.toBytes(aliasName).length;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] aliasBytes = Convert.toBytes(aliasName);
            buffer.put((byte)aliasBytes.length);
            buffer.put(aliasBytes);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("alias", aliasName);
        }

        public String getAliasName(){
            return aliasName;
        }
    }

    public final static class MessagingPollCreation extends AbstractAttachment {

        private final String pollName;
        private final String pollDescription;
        private final String[] pollOptions;
        private final byte minNumberOfOptions, maxNumberOfOptions;
        private final boolean optionsAreBinary;

        MessagingPollCreation(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.pollName = Convert.readString(buffer, buffer.getShort(), Constants.MAX_POLL_NAME_LENGTH);
            this.pollDescription = Convert.readString(buffer, buffer.getShort(), Constants.MAX_POLL_DESCRIPTION_LENGTH);
            int numberOfOptions = buffer.get();
            if (numberOfOptions > Constants.MAX_POLL_OPTION_COUNT) {
                throw new NxtException.NotValidException("Invalid number of poll options: " + numberOfOptions);
            }
            this.pollOptions = new String[numberOfOptions];
            for (int i = 0; i < numberOfOptions; i++) {
                pollOptions[i] = Convert.readString(buffer, buffer.getShort(), Constants.MAX_POLL_OPTION_LENGTH);
            }
            this.minNumberOfOptions = buffer.get();
            this.maxNumberOfOptions = buffer.get();
            this.optionsAreBinary = buffer.get() != 0;
        }

        MessagingPollCreation(JSONObject attachmentData) {
            super(attachmentData);
            this.pollName = ((String) attachmentData.get("name")).trim();
            this.pollDescription = ((String) attachmentData.get("description")).trim();
            JSONArray options = (JSONArray) attachmentData.get("options");
            this.pollOptions = new String[options.size()];
            for (int i = 0; i < pollOptions.length; i++) {
                pollOptions[i] = ((String) options.get(i)).trim();
            }
            this.minNumberOfOptions = ((Long) attachmentData.get("minNumberOfOptions")).byteValue();
            this.maxNumberOfOptions = ((Long) attachmentData.get("maxNumberOfOptions")).byteValue();
            this.optionsAreBinary = (Boolean) attachmentData.get("optionsAreBinary");
        }

        public MessagingPollCreation(String pollName, String pollDescription, String[] pollOptions, byte minNumberOfOptions,
                                     byte maxNumberOfOptions, boolean optionsAreBinary) {
            this.pollName = pollName;
            this.pollDescription = pollDescription;
            this.pollOptions = pollOptions;
            this.minNumberOfOptions = minNumberOfOptions;
            this.maxNumberOfOptions = maxNumberOfOptions;
            this.optionsAreBinary = optionsAreBinary;
        }

        @Override
        String getAppendixName() {
            return "PollCreation";
        }

        @Override
        int getMySize() {
            int size = 2 + Convert.toBytes(pollName).length + 2 + Convert.toBytes(pollDescription).length + 1;
            for (String pollOption : pollOptions) {
                size += 2 + Convert.toBytes(pollOption).length;
            }
            size +=  1 + 1 + 1;
            return size;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] name = Convert.toBytes(this.pollName);
            byte[] description = Convert.toBytes(this.pollDescription);
            byte[][] options = new byte[this.pollOptions.length][];
            for (int i = 0; i < this.pollOptions.length; i++) {
                options[i] = Convert.toBytes(this.pollOptions[i]);
            }
            buffer.putShort((short)name.length);
            buffer.put(name);
            buffer.putShort((short)description.length);
            buffer.put(description);
            buffer.put((byte) options.length);
            for (byte[] option : options) {
                buffer.putShort((short) option.length);
                buffer.put(option);
            }
            buffer.put(this.minNumberOfOptions);
            buffer.put(this.maxNumberOfOptions);
            buffer.put(this.optionsAreBinary ? (byte)1 : (byte)0);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("name", this.pollName);
            attachment.put("description", this.pollDescription);
            JSONArray options = new JSONArray();
            if (this.pollOptions != null) {
                Collections.addAll(options, this.pollOptions);
            }
            attachment.put("options", options);
            attachment.put("minNumberOfOptions", this.minNumberOfOptions);
            attachment.put("maxNumberOfOptions", this.maxNumberOfOptions);
            attachment.put("optionsAreBinary", this.optionsAreBinary);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.POLL_CREATION;
        }

        public String getPollName() { return pollName; }

        public String getPollDescription() { return pollDescription; }

        public String[] getPollOptions() { return pollOptions; }

        public byte getMinNumberOfOptions() { return minNumberOfOptions; }

        public byte getMaxNumberOfOptions() { return maxNumberOfOptions; }

        public boolean isOptionsAreBinary() { return optionsAreBinary; }

    }

    public final static class MessagingVoteCasting extends AbstractAttachment {

        private final long pollId;
        private final byte[] pollVote;

        MessagingVoteCasting(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.pollId = buffer.getLong();
            int numberOfOptions = buffer.get();
            if (numberOfOptions > Constants.MAX_POLL_OPTION_COUNT) {
                throw new NxtException.NotValidException("Error parsing vote casting parameters");
            }
            this.pollVote = new byte[numberOfOptions];
            buffer.get(pollVote);
        }

        MessagingVoteCasting(JSONObject attachmentData) {
            super(attachmentData);
            this.pollId = Convert.parseUnsignedLong((String)attachmentData.get("pollId"));
            JSONArray vote = (JSONArray)attachmentData.get("vote");
            this.pollVote = new byte[vote.size()];
            for (int i = 0; i < pollVote.length; i++) {
                pollVote[i] = ((Long) vote.get(i)).byteValue();
            }
        }

        public MessagingVoteCasting(long pollId, byte[] pollVote) {
            this.pollId = pollId;
            this.pollVote = pollVote;
        }

        @Override
        String getAppendixName() {
            return "VoteCasting";
        }

        @Override
        int getMySize() {
            return 8 + 1 + this.pollVote.length;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(this.pollId);
            buffer.put((byte) this.pollVote.length);
            buffer.put(this.pollVote);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("pollId", Convert.toUnsignedLong(this.pollId));
            JSONArray vote = new JSONArray();
            if (this.pollVote != null) {
                for (byte aPollVote : this.pollVote) {
                    vote.add(aPollVote);
                }
            }
            attachment.put("vote", vote);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.VOTE_CASTING;
        }

        public long getPollId() { return pollId; }

        public byte[] getPollVote() { return pollVote; }

    }

    public final static class MessagingHubAnnouncement extends AbstractAttachment {

        private final long minFeePerByteNQT;
        private final String[] uris;

        MessagingHubAnnouncement(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.minFeePerByteNQT = buffer.getLong();
            int numberOfUris = buffer.get();
            if (numberOfUris > Constants.MAX_HUB_ANNOUNCEMENT_URIS) {
                throw new NxtException.NotValidException("Invalid number of URIs: " + numberOfUris);
            }
            this.uris = new String[numberOfUris];
            for (int i = 0; i < uris.length; i++) {
                uris[i] = Convert.readString(buffer, buffer.getShort(), Constants.MAX_HUB_ANNOUNCEMENT_URI_LENGTH);
            }
        }

        MessagingHubAnnouncement(JSONObject attachmentData) throws NxtException.NotValidException {
            super(attachmentData);
            this.minFeePerByteNQT = (Long) attachmentData.get("minFeePerByte");
            try {
                JSONArray urisData = (JSONArray) attachmentData.get("uris");
                this.uris = new String[urisData.size()];
                for (int i = 0; i < uris.length; i++) {
                    uris[i] = (String) urisData.get(i);
                }
            } catch (RuntimeException e) {
                throw new NxtException.NotValidException("Error parsing hub terminal announcement parameters", e);
            }
        }

        public MessagingHubAnnouncement(long minFeePerByteNQT, String[] uris) {
            this.minFeePerByteNQT = minFeePerByteNQT;
            this.uris = uris;
        }

        @Override
        String getAppendixName() {
            return "HubAnnouncement";
        }

        @Override
        int getMySize() {
            int size = 8 + 1;
            for (String uri : uris) {
                size += 2 + Convert.toBytes(uri).length;
            }
            return size;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(minFeePerByteNQT);
            buffer.put((byte) uris.length);
            for (String uri : uris) {
                byte[] uriBytes = Convert.toBytes(uri);
                buffer.putShort((short)uriBytes.length);
                buffer.put(uriBytes);
            }
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("minFeePerByteNQT", minFeePerByteNQT);
            JSONArray uris = new JSONArray();
            Collections.addAll(uris, this.uris);
            attachment.put("uris", uris);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.HUB_ANNOUNCEMENT;
        }

        public long getMinFeePerByteNQT() {
            return minFeePerByteNQT;
        }

        public String[] getUris() {
            return uris;
        }

    }

    public final static class MessagingAccountInfo extends AbstractAttachment {

        private final String name;
        private final String description;

        MessagingAccountInfo(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.name = Convert.readString(buffer, buffer.get(), Constants.MAX_ACCOUNT_NAME_LENGTH);
            this.description = Convert.readString(buffer, buffer.getShort(), Constants.MAX_ACCOUNT_DESCRIPTION_LENGTH);
        }

        MessagingAccountInfo(JSONObject attachmentData) {
            super(attachmentData);
            this.name = Convert.nullToEmpty((String) attachmentData.get("name"));
            this.description = Convert.nullToEmpty((String) attachmentData.get("description"));
        }

        public MessagingAccountInfo(String name, String description) {
            this.name = name;
            this.description = description;
        }

        @Override
        String getAppendixName() {
            return "AccountInfo";
        }

        @Override
        int getMySize() {
            return 1 + Convert.toBytes(name).length + 2 + Convert.toBytes(description).length;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] name = Convert.toBytes(this.name);
            byte[] description = Convert.toBytes(this.description);
            buffer.put((byte)name.length);
            buffer.put(name);
            buffer.putShort((short) description.length);
            buffer.put(description);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("name", name);
            attachment.put("description", description);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.Messaging.ACCOUNT_INFO;
        }

        public String getName() {
            return name;
        }

        public String getDescription() {
            return description;
        }

    }

    public final static class ColoredCoinsAssetIssuance extends AbstractAttachment {

        private final String name;
        private final String description;
        private final long quantityQNT;
        private final byte decimals;

        ColoredCoinsAssetIssuance(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.name = Convert.readString(buffer, buffer.get(), Constants.MAX_ASSET_NAME_LENGTH);
            this.description = Convert.readString(buffer, buffer.getShort(), Constants.MAX_ASSET_DESCRIPTION_LENGTH);
            this.quantityQNT = buffer.getLong();
            this.decimals = buffer.get();
        }

        ColoredCoinsAssetIssuance(JSONObject attachmentData) {
            super(attachmentData);
            this.name = (String) attachmentData.get("name");
            this.description = Convert.nullToEmpty((String) attachmentData.get("description"));
            this.quantityQNT = Convert.parseLong(attachmentData.get("quantityQNT"));
            this.decimals = ((Long) attachmentData.get("decimals")).byteValue();
        }

        public ColoredCoinsAssetIssuance(String name, String description, long quantityQNT, byte decimals) {
            this.name = name;
            this.description = Convert.nullToEmpty(description);
            this.quantityQNT = quantityQNT;
            this.decimals = decimals;
        }

        @Override
        String getAppendixName() {
            return "AssetIssuance";
        }

        @Override
        int getMySize() {
            return 1 + Convert.toBytes(name).length + 2 + Convert.toBytes(description).length + 8 + 1;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] name = Convert.toBytes(this.name);
            byte[] description = Convert.toBytes(this.description);
            buffer.put((byte)name.length);
            buffer.put(name);
            buffer.putShort((short) description.length);
            buffer.put(description);
            buffer.putLong(quantityQNT);
            buffer.put(decimals);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("name", name);
            attachment.put("description", description);
            attachment.put("quantityQNT", quantityQNT);
            attachment.put("decimals", decimals);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.ColoredCoins.ASSET_ISSUANCE;
        }

        public String getName() {
            return name;
        }

        public String getDescription() {
            return description;
        }

        public long getQuantityQNT() {
            return quantityQNT;
        }

        public byte getDecimals() {
            return decimals;
        }
    }

    public final static class ColoredCoinsAssetTransfer extends AbstractAttachment {

        private final long assetId;
        private final long quantityQNT;
        private final String comment;

        ColoredCoinsAssetTransfer(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.assetId = buffer.getLong();
            this.quantityQNT = buffer.getLong();
            this.comment = getVersion() == 0 ? Convert.readString(buffer, buffer.getShort(), Constants.MAX_ASSET_TRANSFER_COMMENT_LENGTH) : null;
        }

        ColoredCoinsAssetTransfer(JSONObject attachmentData) {
            super(attachmentData);
            this.assetId = Convert.parseUnsignedLong((String) attachmentData.get("asset"));
            this.quantityQNT = Convert.parseLong(attachmentData.get("quantityQNT"));
            this.comment = getVersion() == 0 ? Convert.nullToEmpty((String) attachmentData.get("comment")) : null;
        }

        public ColoredCoinsAssetTransfer(long assetId, long quantityQNT) {
            this.assetId = assetId;
            this.quantityQNT = quantityQNT;
            this.comment = null;
        }

        @Override
        String getAppendixName() {
            return "AssetTransfer";
        }

        @Override
        int getMySize() {
            return 8 + 8 + (getVersion() == 0 ? (2 + Convert.toBytes(comment).length) : 0);
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(assetId);
            buffer.putLong(quantityQNT);
            if (getVersion() == 0 && comment != null) {
                byte[] commentBytes = Convert.toBytes(this.comment);
                buffer.putShort((short) commentBytes.length);
                buffer.put(commentBytes);
            }
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("asset", Convert.toUnsignedLong(assetId));
            attachment.put("quantityQNT", quantityQNT);
            if (getVersion() == 0) {
                attachment.put("comment", comment);
            }
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.ColoredCoins.ASSET_TRANSFER;
        }

        public long getAssetId() {
            return assetId;
        }

        public long getQuantityQNT() {
            return quantityQNT;
        }

        public String getComment() {
            return comment;
        }

    }

    abstract static class ColoredCoinsOrderPlacement extends AbstractAttachment {

        private final long assetId;
        private final long quantityQNT;
        private final long priceNQT;

        private ColoredCoinsOrderPlacement(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.assetId = buffer.getLong();
            this.quantityQNT = buffer.getLong();
            this.priceNQT = buffer.getLong();
        }

        private ColoredCoinsOrderPlacement(JSONObject attachmentData) {
            super(attachmentData);
            this.assetId = Convert.parseUnsignedLong((String) attachmentData.get("asset"));
            this.quantityQNT = Convert.parseLong(attachmentData.get("quantityQNT"));
            this.priceNQT = Convert.parseLong(attachmentData.get("priceNQT"));
        }

        private ColoredCoinsOrderPlacement(long assetId, long quantityQNT, long priceNQT) {
            this.assetId = assetId;
            this.quantityQNT = quantityQNT;
            this.priceNQT = priceNQT;
        }

        @Override
        int getMySize() {
            return 8 + 8 + 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(assetId);
            buffer.putLong(quantityQNT);
            buffer.putLong(priceNQT);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("asset", Convert.toUnsignedLong(assetId));
            attachment.put("quantityQNT", quantityQNT);
            attachment.put("priceNQT", priceNQT);
        }

        public long getAssetId() {
            return assetId;
        }

        public long getQuantityQNT() {
            return quantityQNT;
        }

        public long getPriceNQT() {
            return priceNQT;
        }
    }

    public final static class ColoredCoinsAskOrderPlacement extends ColoredCoinsOrderPlacement {

        ColoredCoinsAskOrderPlacement(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
        }

        ColoredCoinsAskOrderPlacement(JSONObject attachmentData) {
            super(attachmentData);
        }

        public ColoredCoinsAskOrderPlacement(long assetId, long quantityQNT, long priceNQT) {
            super(assetId, quantityQNT, priceNQT);
        }

        @Override
        String getAppendixName() {
            return "AskOrderPlacement";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.ColoredCoins.ASK_ORDER_PLACEMENT;
        }

    }

    public final static class ColoredCoinsBidOrderPlacement extends ColoredCoinsOrderPlacement {

        ColoredCoinsBidOrderPlacement(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
        }

        ColoredCoinsBidOrderPlacement(JSONObject attachmentData) {
            super(attachmentData);
        }

        public ColoredCoinsBidOrderPlacement(long assetId, long quantityQNT, long priceNQT) {
            super(assetId, quantityQNT, priceNQT);
        }

        @Override
        String getAppendixName() {
            return "BidOrderPlacement";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.ColoredCoins.BID_ORDER_PLACEMENT;
        }

    }

    abstract static class ColoredCoinsOrderCancellation extends AbstractAttachment {

        private final long orderId;

        private ColoredCoinsOrderCancellation(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.orderId = buffer.getLong();
        }

        private ColoredCoinsOrderCancellation(JSONObject attachmentData) {
            super(attachmentData);
            this.orderId = Convert.parseUnsignedLong((String) attachmentData.get("order"));
        }

        private ColoredCoinsOrderCancellation(long orderId) {
            this.orderId = orderId;
        }

        @Override
        int getMySize() {
            return 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(orderId);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("order", Convert.toUnsignedLong(orderId));
        }

        public long getOrderId() {
            return orderId;
        }
    }

    public final static class ColoredCoinsAskOrderCancellation extends ColoredCoinsOrderCancellation {

        ColoredCoinsAskOrderCancellation(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
        }

        ColoredCoinsAskOrderCancellation(JSONObject attachmentData) {
            super(attachmentData);
        }

        public ColoredCoinsAskOrderCancellation(long orderId) {
            super(orderId);
        }

        @Override
        String getAppendixName() {
            return "AskOrderCancellation";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.ColoredCoins.ASK_ORDER_CANCELLATION;
        }

    }

    public final static class ColoredCoinsBidOrderCancellation extends ColoredCoinsOrderCancellation {

        ColoredCoinsBidOrderCancellation(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
        }

        ColoredCoinsBidOrderCancellation(JSONObject attachmentData) {
            super(attachmentData);
        }

        public ColoredCoinsBidOrderCancellation(long orderId) {
            super(orderId);
        }

        @Override
        String getAppendixName() {
            return "BidOrderCancellation";
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.ColoredCoins.BID_ORDER_CANCELLATION;
        }

    }

    public final static class DigitalGoodsListing extends AbstractAttachment {

        private final String name;
        private final String description;
        private final String tags;
        private final int quantity;
        private final long priceNQT;

        DigitalGoodsListing(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.name = Convert.readString(buffer, buffer.getShort(), Constants.MAX_DGS_LISTING_NAME_LENGTH);
            this.description = Convert.readString(buffer, buffer.getShort(), Constants.MAX_DGS_LISTING_DESCRIPTION_LENGTH);
            this.tags = Convert.readString(buffer, buffer.getShort(), Constants.MAX_DGS_LISTING_TAGS_LENGTH);
            this.quantity = buffer.getInt();
            this.priceNQT = buffer.getLong();
        }

        DigitalGoodsListing(JSONObject attachmentData) {
            super(attachmentData);
            this.name = (String) attachmentData.get("name");
            this.description = (String) attachmentData.get("description");
            this.tags = (String) attachmentData.get("tags");
            this.quantity = ((Long) attachmentData.get("quantity")).intValue();
            this.priceNQT = Convert.parseLong(attachmentData.get("priceNQT"));
        }

        public DigitalGoodsListing(String name, String description, String tags, int quantity, long priceNQT) {
            this.name = name;
            this.description = description;
            this.tags = tags;
            this.quantity = quantity;
            this.priceNQT = priceNQT;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsListing";
        }

        @Override
        int getMySize() {
            return 2 + Convert.toBytes(name).length + 2 + Convert.toBytes(description).length + 2
                        + Convert.toBytes(tags).length + 4 + 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            byte[] nameBytes = Convert.toBytes(name);
            buffer.putShort((short) nameBytes.length);
            buffer.put(nameBytes);
            byte[] descriptionBytes = Convert.toBytes(description);
            buffer.putShort((short) descriptionBytes.length);
            buffer.put(descriptionBytes);
            byte[] tagsBytes = Convert.toBytes(tags);
            buffer.putShort((short) tagsBytes.length);
            buffer.put(tagsBytes);
            buffer.putInt(quantity);
            buffer.putLong(priceNQT);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("name", name);
            attachment.put("description", description);
            attachment.put("tags", tags);
            attachment.put("quantity", quantity);
            attachment.put("priceNQT", priceNQT);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.LISTING;
        }

        public String getName() { return name; }

        public String getDescription() { return description; }

        public String getTags() { return tags; }

        public int getQuantity() { return quantity; }

        public long getPriceNQT() { return priceNQT; }

    }

    public final static class DigitalGoodsDelisting extends AbstractAttachment {

        private final long goodsId;

        DigitalGoodsDelisting(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.goodsId = buffer.getLong();
        }

        DigitalGoodsDelisting(JSONObject attachmentData) {
            super(attachmentData);
            this.goodsId = Convert.parseUnsignedLong((String)attachmentData.get("goods"));
        }

        public DigitalGoodsDelisting(long goodsId) {
            this.goodsId = goodsId;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsDelisting";
        }

        @Override
        int getMySize() {
            return 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(goodsId);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("goods", Convert.toUnsignedLong(goodsId));
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.DELISTING;
        }

        public long getGoodsId() { return goodsId; }

    }

    public final static class DigitalGoodsPriceChange extends AbstractAttachment {

        private final long goodsId;
        private final long priceNQT;

        DigitalGoodsPriceChange(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.goodsId = buffer.getLong();
            this.priceNQT = buffer.getLong();
        }

        DigitalGoodsPriceChange(JSONObject attachmentData) {
            super(attachmentData);
            this.goodsId = Convert.parseUnsignedLong((String)attachmentData.get("goods"));
            this.priceNQT = Convert.parseLong(attachmentData.get("priceNQT"));
        }

        public DigitalGoodsPriceChange(long goodsId, long priceNQT) {
            this.goodsId = goodsId;
            this.priceNQT = priceNQT;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsPriceChange";
        }

        @Override
        int getMySize() {
            return 8 + 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(goodsId);
            buffer.putLong(priceNQT);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("goods", Convert.toUnsignedLong(goodsId));
            attachment.put("priceNQT", priceNQT);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.PRICE_CHANGE;
        }

        public long getGoodsId() { return goodsId; }

        public long getPriceNQT() { return priceNQT; }

    }

    public final static class DigitalGoodsQuantityChange extends AbstractAttachment {

        private final long goodsId;
        private final int deltaQuantity;

        DigitalGoodsQuantityChange(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.goodsId = buffer.getLong();
            this.deltaQuantity = buffer.getInt();
        }

        DigitalGoodsQuantityChange(JSONObject attachmentData) {
            super(attachmentData);
            this.goodsId = Convert.parseUnsignedLong((String)attachmentData.get("goods"));
            this.deltaQuantity = ((Long)attachmentData.get("deltaQuantity")).intValue();
        }

        public DigitalGoodsQuantityChange(long goodsId, int deltaQuantity) {
            this.goodsId = goodsId;
            this.deltaQuantity = deltaQuantity;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsQuantityChange";
        }

        @Override
        int getMySize() {
            return 8 + 4;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(goodsId);
            buffer.putInt(deltaQuantity);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("goods", Convert.toUnsignedLong(goodsId));
            attachment.put("deltaQuantity", deltaQuantity);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.QUANTITY_CHANGE;
        }

        public long getGoodsId() { return goodsId; }

        public int getDeltaQuantity() { return deltaQuantity; }

    }

    public final static class DigitalGoodsPurchase extends AbstractAttachment {

        private final long goodsId;
        private final int quantity;
        private final long priceNQT;
        private final int deliveryDeadlineTimestamp;

        DigitalGoodsPurchase(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.goodsId = buffer.getLong();
            this.quantity = buffer.getInt();
            this.priceNQT = buffer.getLong();
            this.deliveryDeadlineTimestamp = buffer.getInt();
        }

        DigitalGoodsPurchase(JSONObject attachmentData) {
            super(attachmentData);
            this.goodsId = Convert.parseUnsignedLong((String)attachmentData.get("goods"));
            this.quantity = ((Long)attachmentData.get("quantity")).intValue();
            this.priceNQT = Convert.parseLong(attachmentData.get("priceNQT"));
            this.deliveryDeadlineTimestamp = ((Long)attachmentData.get("deliveryDeadlineTimestamp")).intValue();
        }

        public DigitalGoodsPurchase(long goodsId, int quantity, long priceNQT, int deliveryDeadlineTimestamp) {
            this.goodsId = goodsId;
            this.quantity = quantity;
            this.priceNQT = priceNQT;
            this.deliveryDeadlineTimestamp = deliveryDeadlineTimestamp;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsPurchase";
        }

        @Override
        int getMySize() {
            return 8 + 4 + 8 + 4;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(goodsId);
            buffer.putInt(quantity);
            buffer.putLong(priceNQT);
            buffer.putInt(deliveryDeadlineTimestamp);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("goods", Convert.toUnsignedLong(goodsId));
            attachment.put("quantity", quantity);
            attachment.put("priceNQT", priceNQT);
            attachment.put("deliveryDeadlineTimestamp", deliveryDeadlineTimestamp);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.PURCHASE;
        }

        public long getGoodsId() { return goodsId; }

        public int getQuantity() { return quantity; }

        public long getPriceNQT() { return priceNQT; }

        public int getDeliveryDeadlineTimestamp() { return deliveryDeadlineTimestamp; }

    }

    public final static class DigitalGoodsDelivery extends AbstractAttachment {

        private final long purchaseId;
        private final EncryptedData goods;
        private final long discountNQT;
        private final boolean goodsIsText;

        DigitalGoodsDelivery(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
            super(buffer, transactionVersion);
            this.purchaseId = buffer.getLong();
            int length = buffer.getInt();
            goodsIsText = length < 0;
            if (length < 0) {
                length &= Integer.MAX_VALUE;
            }
            this.goods = EncryptedData.readEncryptedData(buffer, length, Constants.MAX_DGS_GOODS_LENGTH);
            this.discountNQT = buffer.getLong();
        }

        DigitalGoodsDelivery(JSONObject attachmentData) {
            super(attachmentData);
            this.purchaseId = Convert.parseUnsignedLong((String)attachmentData.get("purchase"));
            this.goods = new EncryptedData(Convert.parseHexString((String)attachmentData.get("goodsData")),
                    Convert.parseHexString((String)attachmentData.get("goodsNonce")));
            this.discountNQT = Convert.parseLong(attachmentData.get("discountNQT"));
            this.goodsIsText = Boolean.TRUE.equals(attachmentData.get("goodsIsText"));
        }

        public DigitalGoodsDelivery(long purchaseId, EncryptedData goods, boolean goodsIsText, long discountNQT) {
            this.purchaseId = purchaseId;
            this.goods = goods;
            this.discountNQT = discountNQT;
            this.goodsIsText = goodsIsText;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsDelivery";
        }

        @Override
        int getMySize() {
            return 8 + 4 + goods.getSize() + 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(purchaseId);
            buffer.putInt(goodsIsText ? goods.getData().length | Integer.MIN_VALUE : goods.getData().length);
            buffer.put(goods.getData());
            buffer.put(goods.getNonce());
            buffer.putLong(discountNQT);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("purchase", Convert.toUnsignedLong(purchaseId));
            attachment.put("goodsData", Convert.toHexString(goods.getData()));
            attachment.put("goodsNonce", Convert.toHexString(goods.getNonce()));
            attachment.put("discountNQT", discountNQT);
            attachment.put("goodsIsText", goodsIsText);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.DELIVERY;
        }

        public long getPurchaseId() { return purchaseId; }

        public EncryptedData getGoods() { return goods; }

        public long getDiscountNQT() { return discountNQT; }

        public boolean goodsIsText() {
            return goodsIsText;
        }

    }

    public final static class DigitalGoodsFeedback extends AbstractAttachment {

        private final long purchaseId;

        DigitalGoodsFeedback(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.purchaseId = buffer.getLong();
        }

        DigitalGoodsFeedback(JSONObject attachmentData) {
            super(attachmentData);
            this.purchaseId = Convert.parseUnsignedLong((String)attachmentData.get("purchase"));
        }

        public DigitalGoodsFeedback(long purchaseId) {
            this.purchaseId = purchaseId;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsFeedback";
        }

        @Override
        int getMySize() {
            return 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(purchaseId);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("purchase", Convert.toUnsignedLong(purchaseId));
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.FEEDBACK;
        }

        public long getPurchaseId() { return purchaseId; }

    }

    public final static class DigitalGoodsRefund extends AbstractAttachment {

        private final long purchaseId;
        private final long refundNQT;

        DigitalGoodsRefund(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.purchaseId = buffer.getLong();
            this.refundNQT = buffer.getLong();
        }

        DigitalGoodsRefund(JSONObject attachmentData) {
            super(attachmentData);
            this.purchaseId = Convert.parseUnsignedLong((String)attachmentData.get("purchase"));
            this.refundNQT = Convert.parseLong(attachmentData.get("refundNQT"));
        }

        public DigitalGoodsRefund(long purchaseId, long refundNQT) {
            this.purchaseId = purchaseId;
            this.refundNQT = refundNQT;
        }

        @Override
        String getAppendixName() {
            return "DigitalGoodsRefund";
        }

        @Override
        int getMySize() {
            return 8 + 8;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putLong(purchaseId);
            buffer.putLong(refundNQT);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("purchase", Convert.toUnsignedLong(purchaseId));
            attachment.put("refundNQT", refundNQT);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.DigitalGoods.REFUND;
        }

        public long getPurchaseId() { return purchaseId; }

        public long getRefundNQT() { return refundNQT; }

    }

    public final static class AccountControlEffectiveBalanceLeasing extends AbstractAttachment {

        private final short period;

        AccountControlEffectiveBalanceLeasing(ByteBuffer buffer, byte transactionVersion) {
            super(buffer, transactionVersion);
            this.period = buffer.getShort();
        }

        AccountControlEffectiveBalanceLeasing(JSONObject attachmentData) {
            super(attachmentData);
            this.period = ((Long) attachmentData.get("period")).shortValue();
        }

        public AccountControlEffectiveBalanceLeasing(short period) {
            this.period = period;
        }

        @Override
        String getAppendixName() {
            return "EffectiveBalanceLeasing";
        }

        @Override
        int getMySize() {
            return 2;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
            buffer.putShort(period);
        }

        @Override
        void putMyJSON(JSONObject attachment) {
            attachment.put("period", period);
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.AccountControl.EFFECTIVE_BALANCE_LEASING;
        }

        public short getPeriod() {
            return period;
        }
    }

    public final static class BurstMiningRewardRecipientAssignment extends AbstractAttachment {

    	BurstMiningRewardRecipientAssignment(ByteBuffer buffer, byte transactionVersion) {
    		super(buffer, transactionVersion);
    	}

    	BurstMiningRewardRecipientAssignment(JSONObject attachmentData) {
    		super(attachmentData);
    	}

    	public BurstMiningRewardRecipientAssignment() {
    	}

    	@Override
        String getAppendixName() {
            return "RewardRecipientAssignment";
        }

        @Override
        int getMySize() {
            return 0;
        }

        @Override
        void putMyBytes(ByteBuffer buffer) {
        }

        @Override
        void putMyJSON(JSONObject attachment) {
        }

        @Override
        public TransactionType getTransactionType() {
            return TransactionType.BurstMining.REWARD_RECIPIENT_ASSIGNMENT;
        }
    }

    public final static class AdvancedPaymentEscrowCreation extends AbstractAttachment {

    	private final Long amountNQT;
    	private final byte requiredSigners;
    	private final SortedSet<Long> signers = new TreeSet<>();
    	private final int deadline;
    	private final Escrow.DecisionType deadlineAction;

    	AdvancedPaymentEscrowCreation(ByteBuffer buffer, byte transactionVersion) throws NxtException.NotValidException {
    		super(buffer, transactionVersion);
    		this.amountNQT = buffer.getLong();
    		this.deadline = buffer.getInt();
    		this.deadlineAction = Escrow.byteToDecision(buffer.get());
    		this.requiredSigners = buffer.get();
    		byte totalSigners = buffer.get();
    		if(totalSigners > 10 || totalSigners <= 0) {
    			throw new NxtException.NotValidException("Invalid number of signers listed on create escrow transaction");
    		}
    		for(int i = 0; i < totalSigners; i++) {
    			if(!this.signers.add(buffer.getLong())) {
    				throw new NxtException.NotValidException("Duplicate signer on escrow creation");
    			}
    		}
    	}

    	AdvancedPaymentEscrowCreation(JSONObject attachmentData) throws NxtException.NotValidException {
    		super(attachmentData);
    		this.amountNQT = Convert.parseUnsignedLong((String)attachmentData.get("amountNQT"));
    		this.deadline = ((Long)attachmentData.get("deadline")).intValue();
    		this.deadlineAction = Escrow.stringToDecision((String)attachmentData.get("deadlineAction"));
    		this.requiredSigners = ((Long)attachmentData.get("requiredSigners")).byteValue();
    		int totalSigners = ((JSONArray)attachmentData.get("signers")).size();
    		if(totalSigners > 10 || totalSigners <= 0) {
    			throw new NxtException.NotValidException("Invalid number of signers listed on create escrow transaction");
    		}
    		//this.signers.addAll((JSONArray)attachmentData.get("signers"));
    		JSONArray signersJson = (JSONArray)attachmentData.get("signers");
    		for(int i = 0; i < signersJson.size(); i++) {
    			this.signers.add(Convert.parseUnsignedLong((String)signersJson.get(i)));
    		}
    		if(this.signers.size() != ((JSONArray)attachmentData.get("signers")).size()) {
    			throw new NxtException.NotValidException("Duplicate signer on escrow creation");
    		}
    	}

    	public AdvancedPaymentEscrowCreation(Long amountNQT, int deadline, Escrow.DecisionType deadlineAction,
    											  int requiredSigners, Collection<Long> signers) throws NxtException.NotValidException {
    		this.amountNQT = amountNQT;
    		this.deadline = deadline;
    		this.deadlineAction = deadlineAction;
    		this.requiredSigners = (byte)requiredSigners;
    		if(signers.size() > 10 || signers.size() == 0) {
    			throw new NxtException.NotValidException("Invalid number of signers listed on create escrow transaction");
    		}
    		this.signers.addAll(signers);
    		if(this.signers.size() != signers.size()) {
    			throw new NxtException.NotValidException("Duplicate signer on escrow creation");
    		}
    	}

    	@Override
    	String getAppendixName() {
    		return "EscrowCreation";
    	}

    	@Override
    	int getMySize() {
    		int size = 8 + 4 + 1 + 1 + 1;
    		size += (signers.size() * 8);
    		return size;
    	}

    	@Override
    	void putMyBytes(ByteBuffer buffer) {
    		buffer.putLong(this.amountNQT);
    		buffer.putInt(this.deadline);
    		buffer.put(Escrow.decisionToByte(this.deadlineAction));
    		buffer.put(this.requiredSigners);
    		byte totalSigners = (byte) this.signers.size();
    		buffer.put(totalSigners);
    		for(Long id : this.signers) {
    			buffer.putLong(id);
    		}
    	}

    	@Override
    	void putMyJSON(JSONObject attachment) {
    		attachment.put("amountNQT", Convert.toUnsignedLong(this.amountNQT));
    		attachment.put("deadline", this.deadline);
    		attachment.put("deadlineAction", Escrow.decisionToString(this.deadlineAction));
    		attachment.put("requiredSigners", (int)this.requiredSigners);
    		JSONArray ids = new JSONArray();
    		//ids.addAll(this.signers);
    		for(Long signer : this.signers) {
    			ids.add(Convert.toUnsignedLong(signer));
    		}
    		attachment.put("signers", ids);
    	}

    	@Override
    	public TransactionType getTransactionType() {
    		return TransactionType.AdvancedPayment.ESCROW_CREATION;
    	}

    	public Long getAmountNQT() { return amountNQT; }

    	public int getDeadline() { return deadline; }

    	public Escrow.DecisionType getDeadlineAction() { return deadlineAction; }

    	public int getRequiredSigners() { return (int)requiredSigners; }

    	public Collection<Long> getSigners() { return Collections.unmodifiableCollection(signers); }

    	public int getTotalSigners() { return signers.size(); }
    }

    public final static class AdvancedPaymentEscrowSign extends AbstractAttachment {

    	private final Long escrowId;
    	private final Escrow.DecisionType decision;

    	AdvancedPaymentEscrowSign(ByteBuffer buffer, byte transactionVersion) {
    		super(buffer, transactionVersion);
    		this.escrowId = buffer.getLong();
    		this.decision = Escrow.byteToDecision(buffer.get());
    	}

    	AdvancedPaymentEscrowSign(JSONObject attachmentData) {
    		super(attachmentData);
    		this.escrowId = Convert.parseUnsignedLong((String)attachmentData.get("escrowId"));
    		this.decision = Escrow.stringToDecision((String)attachmentData.get("decision"));
    	}

    	public AdvancedPaymentEscrowSign(Long escrowId, Escrow.DecisionType decision) {
    		this.escrowId = escrowId;
    		this.decision = decision;
    	}

    	@Override
    	String getAppendixName() {
    		return "EscrowSign";
    	}

    	@Override
    	int getMySize() {
    		return 8 + 1;
    	}

    	@Override
    	void putMyBytes(ByteBuffer buffer) {
    		buffer.putLong(this.escrowId);
    		buffer.put(Escrow.decisionToByte(this.decision));
    	}

    	@Override
    	void putMyJSON(JSONObject attachment) {
    		attachment.put("escrowId", Convert.toUnsignedLong(this.escrowId));
    		attachment.put("decision", Escrow.decisionToString(this.decision));
    	}

    	@Override
    	public TransactionType getTransactionType() {
    		return TransactionType.AdvancedPayment.ESCROW_SIGN;
    	}

    	public Long getEscrowId() { return this.escrowId; }

    	public Escrow.DecisionType getDecision() { return this.decision; }
    }

    public final static class AdvancedPaymentEscrowResult extends AbstractAttachment {

    	private final Long escrowId;
    	private final Escrow.DecisionType decision;

    	AdvancedPaymentEscrowResult(ByteBuffer buffer, byte transactionVersion) {
    		super(buffer, transactionVersion);
    		this.escrowId = buffer.getLong();
    		this.decision = Escrow.byteToDecision(buffer.get());
    	}

    	AdvancedPaymentEscrowResult(JSONObject attachmentData) {
    		super(attachmentData);
    		this.escrowId = Convert.parseUnsignedLong((String) attachmentData.get("escrowId"));
    		this.decision = Escrow.stringToDecision((String)attachmentData.get("decision"));
    	}

    	public AdvancedPaymentEscrowResult(Long escrowId, Escrow.DecisionType decision) {
    		this.escrowId = escrowId;
    		this.decision = decision;
    	}

    	@Override
    	String getAppendixName() {
    		return "EscrowResult";
    	}

    	@Override
    	int getMySize() {
    		return 8 + 1;
    	}

    	@Override
    	void putMyBytes(ByteBuffer buffer) {
    		buffer.putLong(this.escrowId);
    		buffer.put(Escrow.decisionToByte(this.decision));
    	}

    	@Override
    	void putMyJSON(JSONObject attachment) {
    		attachment.put("escrowId", Convert.toUnsignedLong(this.escrowId));
    		attachment.put("decision", Escrow.decisionToString(this.decision));
    	}

    	@Override
    	public TransactionType getTransactionType() {
    		return TransactionType.AdvancedPayment.ESCROW_RESULT;
    	}
    }

    public final static class AdvancedPaymentSubscriptionSubscribe extends AbstractAttachment {

    	private final Integer frequency;

    	AdvancedPaymentSubscriptionSubscribe(ByteBuffer buffer, byte transactionVersion) {
    		super(buffer, transactionVersion);
    		this.frequency = buffer.getInt();
    	}

    	AdvancedPaymentSubscriptionSubscribe(JSONObject attachmentData) {
    		super(attachmentData);
    		this.frequency = ((Long)attachmentData.get("frequency")).intValue();
    	}

    	public AdvancedPaymentSubscriptionSubscribe(int frequency) {
    		this.frequency = frequency;
    	}

    	@Override
    	String getAppendixName() {
    		return "SubscriptionSubscribe";
    	}

    	@Override
    	int getMySize() {
    		return 4;
    	}

    	@Override
    	void putMyBytes(ByteBuffer buffer) {
    		buffer.putInt(this.frequency);
    	}

    	@Override
    	void putMyJSON(JSONObject attachment) {
    		attachment.put("frequency", this.frequency);
    	}

    	@Override
    	public TransactionType getTransactionType() {
    		return TransactionType.AdvancedPayment.SUBSCRIPTION_SUBSCRIBE;
    	}

    	public Integer getFrequency() { return this.frequency; }
    }

    public final static class AdvancedPaymentSubscriptionCancel extends AbstractAttachment {

    	private final Long subscriptionId;

    	AdvancedPaymentSubscriptionCancel(ByteBuffer buffer, byte transactionVersion) {
    		super(buffer, transactionVersion);
    		this.subscriptionId = buffer.getLong();
    	}

    	AdvancedPaymentSubscriptionCancel(JSONObject attachmentData) {
    		super(attachmentData);
    		this.subscriptionId = Convert.parseUnsignedLong((String)attachmentData.get("subscriptionId"));
    	}

    	public AdvancedPaymentSubscriptionCancel(Long subscriptionId) {
    		this.subscriptionId = subscriptionId;
    	}

    	@Override
    	String getAppendixName() {
    		return "SubscriptionCancel";
    	}

    	@Override
    	int getMySize() {
    		return 8;
    	}

    	@Override
    	void putMyBytes(ByteBuffer buffer) {
    		buffer.putLong(subscriptionId);
    	}

    	@Override
    	void putMyJSON(JSONObject attachment) {
    		attachment.put("subscriptionId", Convert.toUnsignedLong(this.subscriptionId));
    	}

    	@Override
    	public TransactionType getTransactionType() {
    		return TransactionType.AdvancedPayment.SUBSCRIPTION_CANCEL;
    	}

    	public Long getSubscriptionId() { return this.subscriptionId; }
    }

    public final static class AdvancedPaymentSubscriptionPayment extends AbstractAttachment {

    	private final Long subscriptionId;

    	AdvancedPaymentSubscriptionPayment(ByteBuffer buffer, byte transactionVersion) {
    		super(buffer, transactionVersion);
    		this.subscriptionId = buffer.getLong();
    	}

    	AdvancedPaymentSubscriptionPayment(JSONObject attachmentData) {
    		super(attachmentData);
    		this.subscriptionId = Convert.parseUnsignedLong((String) attachmentData.get("subscriptionId"));
    	}

    	public AdvancedPaymentSubscriptionPayment(Long subscriptionId) {
    		this.subscriptionId = subscriptionId;
    	}

    	@Override
    	String getAppendixName() {
    		return "SubscriptionPayment";
    	}

    	@Override
    	int getMySize() {
    		return 8;
    	}

    	@Override
    	void putMyBytes(ByteBuffer buffer) {
    		buffer.putLong(this.subscriptionId);
    	}

    	@Override
    	void putMyJSON(JSONObject attachment) {
    		attachment.put("subscriptionId", Convert.toUnsignedLong(this.subscriptionId));
    	}

    	@Override
    	public TransactionType getTransactionType() {
    		return TransactionType.AdvancedPayment.SUBSCRIPTION_PAYMENT;
    	}
    }

    public final static class AutomatedTransactionsCreation extends AbstractAttachment{

        private final String name;
        private final String description;
        private final byte[] creationBytes;

		AutomatedTransactionsCreation(ByteBuffer buffer,
				byte transactionVersion) throws NxtException.NotValidException {
			super(buffer, transactionVersion);

			this.name = Convert.readString( buffer , buffer.get() , Constants.MAX_AUTOMATED_TRANSACTION_NAME_LENGTH );
			this.description = Convert.readString( buffer , buffer.getShort() , Constants.MAX_AUTOMATED_TRANSACTION_DESCRIPTION_LENGTH );

			byte[] dst = new byte[ buffer.capacity() - buffer.position() ];
			buffer.get( dst , 0 , buffer.capacity() - buffer.position() );
			this.creationBytes = dst;

		}

		AutomatedTransactionsCreation(JSONObject attachmentData) throws NxtException.NotValidException {
			super(attachmentData);

			this.name = ( String ) attachmentData.get( "name" );
			this.description = ( String ) attachmentData.get( "description" );

			this.creationBytes = Convert.parseHexString( (String) attachmentData.get( "creationBytes" ) );

		}

		public AutomatedTransactionsCreation( String name, String description , byte[] creationBytes ) throws NotValidException
		{
			this.name = name;
			this.description = description;
			this.creationBytes = creationBytes;

		}

		@Override
		public TransactionType getTransactionType() {
			return TransactionType.AutomatedTransactions.AUTOMATED_TRANSACTION_CREATION;
		}

		@Override
		String getAppendixName() {
            return "AutomatedTransactionsCreation";
        }
		@Override
		int getMySize() {
            return 1 + Convert.toBytes( name ).length + 2 + Convert.toBytes( description ).length + creationBytes.length;
		}

		@Override
		void putMyBytes(ByteBuffer buffer) {
            byte[] nameBytes = Convert.toBytes( name );
            buffer.put( ( byte ) nameBytes.length );
            buffer.put( nameBytes );
            byte[] descriptionBytes = Convert.toBytes( description );
            buffer.putShort( ( short ) descriptionBytes.length );
            buffer.put( descriptionBytes );

            buffer.put( creationBytes );
		}

		@Override
		void putMyJSON(JSONObject attachment) {
			attachment.put("name", name);
            attachment.put("description", description);
            attachment.put("creationBytes", Convert.toHexString( creationBytes ) );
		}

        public String getName() { return name; }

        public String getDescription() { return description; }

		public byte[] getCreationBytes() {
			return creationBytes;
		}

    }

    /*public final static class AutomatedTransactionsPayment extends AbstractAttachment{

    	AutomatedTransactionsPayment(ByteBuffer buffer,
				byte transactionVersion) throws NxtException.NotValidException {
			super(buffer, transactionVersion);
		}

		AutomatedTransactionsPayment(JSONObject attachmentData) throws NxtException.NotValidException {
			super(attachmentData);
		}

		public AutomatedTransactionsPayment() {
		}

    	@Override
		public TransactionType getTransactionType() {
			return TransactionType.AutomatedTransactions.AT_PAYMENT;
		}

		@Override
		String getAppendixName() {
			return "AutomatedTransactionsPayment";
		}

		@Override
		int getMySize() {
			return 0;
		}

		@Override
		void putMyBytes(ByteBuffer buffer) {
		}

		@Override
		void putMyJSON(JSONObject json) {
		}

    }*/

}


text:
namespace geoff
{

	GeoffAudio::GeoffAudio( )
	{
		// Set up ogg callbacks for reading ogg files
		_callbacks.read_func = geoff_ogg_read;
		_callbacks.seek_func = geoff_ogg_seek;
		_callbacks.close_func = NULL;
		_callbacks.tell_func = geoff_ogg_tell;

		// Set up default device
		_device = alcOpenDevice(NULL);
		_context = alcCreateContext( _device, NULL );
		alcMakeContextCurrent( _context );

		// Set up a listener
		alListener3f( AL_POSITION, 0, 0, 0 );
		alListener3f( AL_VELOCITY, 0, 0, 0 );
		float orientation[6] = {0, 0, -1, 0, 1, 0};
		alListenerfv( AL_ORIENTATION, orientation );

		// Set up a single source that will be fed with data
		alGenSources( 1, &_source );
		alSourcef( _source, AL_PITCH, 1 );
		alSourcef( _source, AL_GAIN, 1 );
		alSource3f( _source, AL_POSITION, 0, 0, 0 );
		alSource3f( _source, AL_VELOCITY, 0, 0, 0 );
		alSourcei( _source, AL_LOOPING, AL_FALSE );

		// Set up the buffers
		alGenBuffers( NUM_BUFFERS, _bufferIds );
		unsigned char bufferData[BUFFER_SIZE];
		memset( bufferData, 0, BUFFER_SIZE );
		for ( int i = 0; i < NUM_BUFFERS; ++i )
		{
			alBufferData( _bufferIds[i], AL_FORMAT_STEREO16, (void*)bufferData, BUFFER_SIZE, 44100 );
			alSourceQueueBuffers( _source, 1, &(_bufferIds[i]) );
		}

		alSourcePlay( _source );

	}

	GeoffAudio::~GeoffAudio( )
	{

		alDeleteBuffers( NUM_BUFFERS, _bufferIds );
		alDeleteSources( 1, &_source );

	}

	void GeoffAudio::update( )
	{

		int processed = 0;
		alGetSourcei( _source, AL_BUFFERS_PROCESSED, &processed );

		if ( processed > 0 )
		{
			geoff::App_obj::current->eventManager->sendEvent( ::String("AudioBufferEmpty") );
		}

	}

	void GeoffAudio::bufferData( haxe::io::Bytes bufferData )
	{
		unsigned int buffer;
		alSourceUnqueueBuffers( _source, 1, &buffer );

		alBufferData( buffer, AL_FORMAT_STEREO16, (void*)&(bufferData->b[0]), BUFFER_SIZE, 44100 );
		alSourceQueueBuffers( _source, 1, &buffer );

		int state;
		alGetSourcei(_source, AL_SOURCE_STATE, &state);
        if(state != AL_PLAYING)
            alSourcePlay(_source);
	}

};

redpajama_set_name: RedPajamaGithub


text:
module VirtualBox
  module COM
    module Interface
      module Version_4_1_X
        class AccessMode < AbstractEnum
          map [:null, :read_only, :read_write]
        end
      end
    end
  end
end


text:
      {{ page.content | markdownify }}

        {% for event in site.events %}
          {% assign loopindex = forloop.index | modulo: 2 %}
          {% capture class %}
          {% if loopindex == 0 %}
            timeline-inverted
          {% endif %}
          {% endcapture %}

{{ event.date }}

                {{ event.description | markdownify }}

        {% endfor %}


text:
<?php
/**
 * @author Ruslan Gumennyi
 *
 *
 */
class RG_Guestbook_IndexController extends Mage_Core_Controller_Front_Action
{
    const XML_PATH_RECAPTCHA_PUB_KEY = 'guestbook/recaptcha/public_key';
    const XML_PATH_RECAPTCHA_PRV_KEY = 'guestbook/recaptcha/private_key';
    const XML_PATH_RECAPTCHA_ENABLED = 'guestbook/recaptcha/enabled';
    const XML_PATH_ENABLED           = 'guestbook/guestbook/enabled';

    protected $_isReCaptchaEnabled = false;
    protected $_isCustomer = false;

    public function preDispatch ()
    {
        parent::preDispatch();
        if (! Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
            $this->norouteAction();
        }
        if (Mage::getStoreConfigFlag(self::XML_PATH_RECAPTCHA_ENABLED)) {
            if (Mage::getStoreConfig(self::XML_PATH_RECAPTCHA_PRV_KEY) &&
             Mage::getStoreConfig(self::XML_PATH_RECAPTCHA_PUB_KEY)) {
                $this->_isReCaptchaEnabled = true;
            }
        }
        if (Mage::getModel('customer/session')->isLoggedIn()) {
            $this->_isReCaptchaEnabled = false;
        }
        if (Mage::getModel('core/session')->getShowList()) {
            $this->_isReCaptchaEnabled = false;
        }

    }

    public function indexAction ()
    {
        $this->loadLayout();
        $this->getLayout()
            ->getBlock('guestbookForm')
            ->setFormAction(Mage::getUrl('*/*/post'));

        if(Mage::getModel('core/session')->getShowList()) {
            $this->getLayout()
                 ->getBlock('records')
                 ->setRecords(Mage::getModel('guestbook/guestbook')->getRecords());
        }

        if ($this->_isReCaptchaEnabled) {
                    $this->getLayout()
                         ->getBlock('recaptcha')
                         ->setEnabled(true)
                         ->setPrvKey(Mage::getStoreConfig(self::XML_PATH_RECAPTCHA_PRV_KEY))
                         ->setPubKey(Mage::getStoreConfig(self::XML_PATH_RECAPTCHA_PUB_KEY));
        }

        $this->_initLayoutMessages('customer/session');
        $this->_initLayoutMessages('catalog/session');

        $this->renderLayout();
    }

    public function postAction ()
    {
        $post = $this->getRequest()->getPost();
        if ($post) {
            $translate = Mage::getSingleton('core/translate');
            /* @var $translate Mage_Core_Model_Translate */
            $translate->setTranslateInline(false);
            try {
                $error = false;

                if ($this->_isReCaptchaEnabled) {
                    $recaptcha_pub_key = Mage::getStoreConfig(self::XML_PATH_RECAPTCHA_PUB_KEY);
                    $recaptcha_prv_key = Mage::getStoreConfig(self::XML_PATH_RECAPTCHA_PRV_KEY);

                    $recaptcha = new Zend_Service_ReCaptcha($recaptcha_pub_key, $recaptcha_prv_key);

                    if (! empty($post['recaptcha_response_field'])) {
                        $result = $recaptcha->verify($post['recaptcha_challenge_field'], $post['recaptcha_response_field']);
                        if (! $result->isValid()) {
                            $error = true;
                        }
                    } else {
                        $error = true;
                    }
                }
                if (! Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
                    $error = true;
                }
                if (! Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
                    $error = true;
                }
                if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                    $error = true;
                }
                if ($error) {
                    throw new Exception();
                }
                $data = array(
                        'author_name'  => htmlentities($post['name']),
                        'message_text' => htmlentities($post['comment']),
                        );
                Mage::getModel('guestbook/guestbook')->addRecord($data);
                Mage::getModel('core/session')->setShowList(true);

                $translate->setTranslateInline(true);

                if($post['ajax']) {
                    $this->_forward('defaultList');
                } else {
                    $this->_redirect('*/*/');
                }
                return;
            } catch (Exception $e) {
                if($post['ajax']) {
                    $this->_forward('defaultError');
                } else {
                    $translate->setTranslateInline(true);
                    Mage::getSingleton('customer/session')->addError(
                    Mage::helper('guestbook')->__(
                    'Unable to submit your request. Please, try again later'));
                    $this->_redirect('*/*/');
                }
                return;
            }
        } else {
            $this->_redirect('*/*/');
        }
    }

    public function rssAction()
    {
            $records = Mage::getModel('guestbook/guestbook')->getRecords();

            $feedArray = array (
                'title'    => 'Guestbook News',
                'link'     => Mage::getUrl('guestbook/index/rss'),
                'language' => 'en-us',
                'charset'  => 'utf-8',
                'pubDate'  => time(),
                'entries'  => array()
            );

            foreach ( $records as $_item ) {
                //$link = Mage::helper('guestbook')->getUrl($_item['news_id']);
                $link = Mage::getUrl('guestbook/index/rss');
                $date = new Zend_Date($_item['date']);

                $feedArray['entries'][] = array (
                    'title'       =>    $_item['author_name'],
                    'link'        =>    $link,
                    'guid'        =>    $link,
                    'description' =>    $_item['message_text'],
                    'lastUpdate'  =>    $date->get(Zend_Date::TIMESTAMP)
                );

            }

            $feed = Zend_Feed::importArray($feedArray, 'rss');
            $feed->send();
            exit;

        }

    protected function defaultListAction()
    {
        $layout = $this->getLayout();
        $layout->getUpdate()
            ->addHandle('guestbook_index_list')
            ->load();

        $layout->generateXml()
               ->generateBlocks();

        $records = $layout->getBlock('records')
                    ->setRecords(Mage::getModel('guestbook/guestbook')->getRecords())
                    ->toHtml();

        echo $records;
    }
    protected function defaultErrorAction()
    {
        $error  = '
';
        $error .= Mage::helper('guestbook')->__(
                    'Unable to submit your request. Please, make sure you typed all correctly, or try again later');
        $error .= '
';
        echo $error;
    }
}
?>


text:
/* jshint node: true */
'use strict';

module.exports = {
  name: 'ember-strong-attrs'
};


text:
package org.lastaflute.di.helper.beans.impl;

import java.lang.reflect.Field;
import java.util.Properties;

import org.lastaflute.di.helper.beans.BeanDesc;
import org.lastaflute.di.helper.beans.exception.BeanNoClassDefFoundError;
import org.lastaflute.di.unit.UnitLastaDiTestCase;

/**
 * @author jflute
 * @since 0.7.6 (2018/03/01 Thursday)
 */
public class BeanDescImplTest extends UnitLastaDiTestCase {

    // ===================================================================================
    //                                                                         Class Error
    //                                                                         ===========
    public void test_classError_basic() {
        // ## Arrange ##
        try {
            // ## Act ##
            new BeanDescImpl(getClass()) {
                @Override
                protected void setupPropertyDescs() {
                    throw new NoClassDefFoundError("sea");
                }
            };
            // ## Assert ##
            fail();
        } catch (BeanNoClassDefFoundError e) {
            log(e);
        }
    }

    // ===================================================================================
    //                                                                    Field Accessible
    //                                                                    ================
    public void test_beAccessible_basic() {
        // ## Arrange ##
        // ## Act ##
        BeanDesc desc = new BeanDescImpl(MaihamaBean.class);
        // ## Assert ##
        int fieldSize = desc.getFieldSize();
        assertNotSame(0, fieldSize);
        for (int i = 0; i < fieldSize; i++) {
            Field field = desc.getField(i);
            log(field);
            assertTrue(field.isAccessible());
        }
    }

    public void test_beAccessible_JDKinternal_basic() {
        // ## Arrange ##
        // ## Act ##
        BeanDesc desc = new BeanDescImpl(Properties.class);
        // ## Assert ##
        int fieldSize = desc.getFieldSize();
        assertNotSame(0, fieldSize);
        for (int i = 0; i < fieldSize; i++) {
            Field field = desc.getField(i);
            log(field);
            assertFalse(field.isAccessible());
        }
    }

    public static class MaihamaBean {

        private String sea;
        private Integer land;

        @Override
        public String toString() {
            return "{" + sea + ", " + land + "}";
        }
    }
}


text:
<?php

namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent;

use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest;

/**
 * @author Maximilian Beckers <beckers.maximilian@gmail.com>
 */
class SkillDisabledRequest extends AlexaSkillEventRequest
{
    const TYPE = 'AlexaSkillEvent.SkillDisabled';

    /**
     * @var SkillDisabledBody|null
     */
    public $body;

    /**
     * @inheritdoc
     */
    public static function fromAmazonRequest(array $amazonRequest): AbstractRequest
    {
        $request = new self();

        $request->type = self::TYPE;
        $request->body = isset($amazonRequest['body']) ? SkillDisabledBody::fromAmazonRequest($amazonRequest['body']) : null;
        $request->setRequestData($amazonRequest);

        return $request;
    }
}


text:
.class final Landroid/hardware/hdmi/HdmiTvClient$1;
.super Landroid/hardware/hdmi/IHdmiControlCallback$Stub;
.source "HdmiTvClient.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Landroid/hardware/hdmi/HdmiTvClient;->getCallbackWrapper(Landroid/hardware/hdmi/HdmiTvClient$SelectCallback;)Landroid/hardware/hdmi/IHdmiControlCallback;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = null
.end annotation

# instance fields
.field final synthetic val$callback:Landroid/hardware/hdmi/HdmiTvClient$SelectCallback;

# direct methods
.method constructor <init>(Landroid/hardware/hdmi/HdmiTvClient$SelectCallback;)V
    .locals 0

    .prologue
    .line 89
    iput-object p1, p0, Landroid/hardware/hdmi/HdmiTvClient$1;->val$callback:Landroid/hardware/hdmi/HdmiTvClient$SelectCallback;

    invoke-direct {p0}, Landroid/hardware/hdmi/IHdmiControlCallback$Stub;-><init>()V

    return-void
.end method

# virtual methods
.method public onComplete(I)V
    .locals 1
    .param p1, "result"    # I

    .prologue
    .line 92
    iget-object v0, p0, Landroid/hardware/hdmi/HdmiTvClient$1;->val$callback:Landroid/hardware/hdmi/HdmiTvClient$SelectCallback;

    invoke-interface {v0, p1}, Landroid/hardware/hdmi/HdmiTvClient$SelectCallback;->onComplete(I)V

    .line 93
    return-void
.end method


text:
body { margin:0; font-size:0.9em; line-height:20px; background:url(../images/body_bckg.jpg) repeat-x #ffffff; font-family: "Myriad Pro", "Trebuchet MS", Arial;}
a { color:#862E54;}
a:hover { text-decoration:none;}

#logo { padding:30px 0 0 40px; height:36px; }
#logo a{ color:#FFFFFF; text-decoration:none; font-weight:bold; height:36px; font-size:26px; text-transform:uppercase;}
#logo a:hover { }
#menu { background:url(../images/menu_bckg.jpg) repeat-x; width:880px; margin:0 auto; height:32px; margin-top:47px;}
#menu ul { margin:0; padding:0;}
#menu ul li{ display:inline-block; float:left; width:110px; list-style:none; text-align:center; height:32px;}
#menu a { display:block; float:left; width:110px; color:#FFFFFF; font-size:12px; text-transform:uppercase; font-weight:bold; text-decoration:none; padding-top:8px;}
#menu a:hover{ background: #862E54; padding-top:8px; height:24px;}

#main { width:100%;}
#content { margin:0 auto; padding:0; width:780px; padding:30px 10px 0px 10px;}
#content-left { margin:0 auto; padding:0; width:525px; padding:0px 0px 0px 0px; float:left}
#content-right { margin:0 auto; padding:0; width:250px; padding:0px 0px 0px 0px; float:right}
#content h1 { margin:0; text-transform:uppercase; font-size:2em;}
#content h2 { margin:0; text-transform:uppercase; font-size:1.5em;}
.red { color:#862E54;}
.green { padding-left: 3px; padding-right: 3px; background-color: #00AA00; color:#FFFFFF;}
.black { padding-left: 3px; padding-right: 3px; background-color: #000000; color:#FFFFFF;}
.little { font-size:0.6em; }
#content p { border-bottom:15px solid #fafafa; padding-bottom:20px;}

#footer {background:url(../images/footer_bckg.jpg) repeat-x #000000; height:102px;}
#left_footer { float:left; padding:40px 0 0 60px; background:url(../images/c.gif) no-repeat 30px 35px; text-transform:uppercase; color:#FFFFFF; font-weight:bold; font-size:11px;}
#left_footer a { color:#FFFFFF;}
#left_footer a:hover { text-decoration:none;}
#right_footer { float:right;  padding:40px 30px 0 0; text-transform:uppercase; color:#FFFFFF; font-weight:bold; font-size:11px; text-align:right;}
#right_footer a { color:#FFFFFF;}
#right_footer a:hover { text-decoration:none;}

.inputArea
{
    font-family: "Myriad Pro", "Trebuchet MS", Arial;
    font-size: 24px;
    margin-bottom: 5px;
    display: block;
    padding: 4px;
    border: solid 1px #85b1de;
    width: 20px;
    background-color: #EDF2F7;
}

div.cajaFaseFinal {
    width: 9em;
    background-color: #E6E6E6;
    margin: 3px;
    padding: 3px;
}


text:
package org.innovateuk.ifs.project.projectdetails.workflow.actions;

import org.innovateuk.ifs.activitylog.resource.ActivityType;
import org.innovateuk.ifs.activitylog.transactional.ActivityLogService;
import org.innovateuk.ifs.project.core.domain.Project;
import org.innovateuk.ifs.project.core.domain.ProjectUser;
import org.innovateuk.ifs.project.resource.ProjectDetailsState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ProjectDetailsCompleteAction extends BaseProjectDetailsAction {

    @Autowired
    private ActivityLogService activityLogService;

    @Override
    protected void doExecute(Project project, ProjectUser projectUserFromContext, ProjectDetailsState newState) {
        activityLogService.recordActivityByProjectId(project.getId(), ActivityType.PROJECT_DETAILS_COMPLETE);
    }
}


text:
package edu.ncsu.csc.nl.model.type;

/**
 * PennBank Part of speech tags
 *
 * @author John
 *
 */
public enum PartOfSpeech {

	CC("CC",'C',"conjunction, coordinating","and, or, but",null),
	CD("CD",'D',"cardinal number","five, three, 13%",null),
	DT("DT",'T',"determiner","the, a, these ",null),
	EX("EX",'E',"existential there","there were six boys ",null),
	FW("FW",'F',"foreign word","mais ",null),
	IN("IN",'I',"conjunction, subordinating or preposition","of, on, before, unless ",null),
	JJ("JJ",'J',"adjective","nice, easy",edu.mit.jwi.item.POS.ADJECTIVE),
	JJR("JJR",'z',"adjective, comparative","nicer, easier",JJ,edu.mit.jwi.item.POS.ADJECTIVE),
	JJS("JJS",'y',"adjective, superlative","nicest, easiest ",JJ,edu.mit.jwi.item.POS.ADJECTIVE),
	LS("LS",'L',"list item marker","",null),
	MD("MD",'M',"verb, modal auxillary","may, should ",edu.mit.jwi.item.POS.VERB),
	NN("NN",'N',"noun, singular or mass","tiger, chair, laughter ",edu.mit.jwi.item.POS.NOUN),
	NNS("NNS",'x',"noun, plural","tigers, chairs, insects ",NN, edu.mit.jwi.item.POS.NOUN),
	NNP("NNP",'w',"noun, proper singular","Germany, God, Alice ",NN,edu.mit.jwi.item.POS.NOUN),
	NNPS("NNPS",'v',"noun, proper plural","we met two Christmases ago ",NN,edu.mit.jwi.item.POS.NOUN),
	PDT("PDT",'R',"predeterminer","both his children ",null),
	PRP("PRP",'P',"pronoun, personal","me, you, it ",edu.mit.jwi.item.POS.NOUN),
	PRP$("PRP$",'O',"pronoun, possessive","my, your, our ",null),
	RB("RB",'A',"adverb","extremely, loudly, hard  ",edu.mit.jwi.item.POS.ADVERB),
	RBR("RBR",'u',"adverb, comparative","better ",RB,edu.mit.jwi.item.POS.ADVERB),
	RBS("RBS",'t',"adverb, superlative","best ",RB,edu.mit.jwi.item.POS.ADVERB),
	RP("RP",'s',"adverb, particle","about, off, up ",RB,edu.mit.jwi.item.POS.ADVERB),
	SYM("SYM",'S',"symbol","% ",null),
	TO("TO",'G',"infinitival to","what to do? ",null),
	UH("UH",'U',"interjection","oh, oops, gosh ",null),
	VB("VB",'V',"verb, base form","think ",edu.mit.jwi.item.POS.VERB),
	VBZ("VBZ",'r',"verb, 3rd person singular present","she thinks ",VB,edu.mit.jwi.item.POS.VERB),
	VBP("VBP",'q',"verb, non-3rd person singular present","I think ", VB,edu.mit.jwi.item.POS.VERB),
	VBD("VBD",'p',"verb, past tense","they thought ",VB,edu.mit.jwi.item.POS.VERB),
	VBN("VBN",'o',"verb, past participle","a sunken ship ",VB,edu.mit.jwi.item.POS.VERB),
	VBG("VBG",'n',"verb, gerund or present participle","thinking is fun ",VB,edu.mit.jwi.item.POS.VERB),
	WDT("WDT",'B',"wh-determiner","which, whatever, whichever ",edu.mit.jwi.item.POS.NOUN),
	WP("WP",'W',"wh-pronoun, personal","what, who, whom ",edu.mit.jwi.item.POS.NOUN),
	WP$("WP$",'H',"wh-pronoun, possessive","whose, whosever ",null),
	WRB("WRB",'K',"wh-adverb","where, when ",edu.mit.jwi.item.POS.ADVERB),
	POS("POS",'_',"","",null), // TODO: Explore when this arises.
	$("$",'$',"","",null),
	COMMA(",",',',"","",null),
	COLON(":",':',"","",null),
	RRB("RRB",']',"","",null),
	LRB("LRB",'[',"","",null),
	LCB("LCB",'{',"","",null),
	RCB("RCB",'}',"","",null),
	LSB("LSB",'>',"","",null),
	RSB("RSB",'<',"","",null),
	NONE("-NONE",'-',"","",null),
	HASH("HASH(#)",'#',"","",null),
	DQ("DQ",'*',"","",null);

	char _singleCharacterLabel;
	String _label;
	String _name;
	String _example;
	edu.mit.jwi.item.POS _wordNetPartOfSpeech;

	/** This allows us to treat singular and plural nouns the same.  Similarly all verbs should be just a verb */
	PartOfSpeech _collapsedPOS;
	PartOfSpeech(String label, char singleCharacterLabel, String name, String example, edu.mit.jwi.item.POS wordNetPOS ) {
		_label = label;
		_singleCharacterLabel = singleCharacterLabel;
		_name  = name;
		_example = example;
		_collapsedPOS = this;
		_wordNetPartOfSpeech = wordNetPOS;

	}
	PartOfSpeech(String label, char singleCharacterLabel, String name, String example, PartOfSpeech collapsed, edu.mit.jwi.item.POS wordNetPOS) {
		this(label,singleCharacterLabel,name,example, wordNetPOS);
		_collapsedPOS = collapsed;
	}

	public String toString() {
		return _label;
	}

	public String getActualLabel() {
		return _label;
	}

	public String getName() {
		return _name;
	}

	public String getExample() {
		return _example;
	}

	public PartOfSpeech getCollapsedPOS() {
		return _collapsedPOS;
	}

	public String getCollapsedLabel() {
		return _collapsedPOS.getActualLabel();
	}

	public static PartOfSpeech retrieve(String tag) {
		switch (tag) {
		  case "-RRB-":  return RRB;
		  case "-LRB-":  return LRB;
		  case "-LCB-":	 return LCB;
		  case "-RCB-":  return RCB;
		  case "-LSB-":  return LSB;
		  case "-RSB-":  return RSB;
		  case "-NONE-": return NONE;
		  case ",":		 return COMMA;
		  case ":":		 return COLON;
		  case "#":    	 return HASH;
		  case "``":     return DQ;
		  default:       return PartOfSpeech.valueOf(PartOfSpeech.class,tag);
		}
	}

	public edu.mit.jwi.item.POS getWordNetPOS() {
		return _wordNetPartOfSpeech;
	}

	public boolean equalsCollapsed(PartOfSpeech pos) {
		//System.out.println(pos.getCollapsedLabel() +":" + this.getCollapsedLabel());
		return this.getCollapsedPOS() == pos.getCollapsedPOS();
	}

	public char getSingleCharacterLabel() {
		return _collapsedPOS._singleCharacterLabel;
	}

	public boolean isPlural() {
		return (this == NNS || this == NNPS);
	}

	public boolean isPronomial() {
		return (this == PRP || this == PRP$  || this == WP || this == WP$);
	}
}


text:
"""Operations for preparing useful quantum states."""

from typing import Iterable, Optional, Sequence, Set, Tuple, Union, cast

import numpy

import cirq
from openfermion import (
        QuadraticHamiltonian,
        gaussian_state_preparation_circuit,
        slater_determinant_preparation_circuit)

from openfermioncirq import Ryxxy

def prepare_gaussian_state(qubits: Sequence[cirq.Qid],
                           quadratic_hamiltonian: QuadraticHamiltonian,
                           occupied_orbitals: Optional[Union[
                               Sequence[int],
                               Tuple[Sequence[int], Sequence[int]]
                               ]]=None,
                           initial_state: Union[int, Sequence[int]]=0
                           ) -> cirq.OP_TREE:
    """Prepare a fermionic Gaussian state from a computational basis state.

    A fermionic Gaussian state is an eigenstate of a quadratic Hamiltonian. If
    the Hamiltonian conserves particle number, then it is a Slater determinant.
    The algorithm used is described in arXiv:1711.05395. It assumes the
    Jordan-Wigner transform.

    Args:
        qubits: The qubits to which to apply the circuit.
        quadratic_hamiltonian: The Hamiltonian whose eigenstate is desired.
        occupied_orbitals: Integers representing the indices of the
            pseudoparticle orbitals to occupy in the Gaussian state.
            If two lists are given, then the first list specifies spin-up
            orbitals and the second list specifies spin-down orbitals,
            and the modes are assumed to be ordered so that
            spin-up modes come before spin-down modes.
            Two lists should be given only if the Hamiltonian contains a
            spin degree of freedom and modes with different spin do not
            interact.
            The orbitals are ordered in ascending order of energy.
            The default behavior is to fill the orbitals with negative energy,
            i.e., prepare the ground state.
        initial_state: The computational basis state that the qubits start in.
            This can be either an integer or a sequence of integers.
            If an integer, it is mapped to a computational basis state via
            "big endian" ordering of the binary representation of the integer.
            For example, the computational basis state on five qubits with
            the first and second qubits set to one is 0b11000, which is 24
            in decimal.
            If a sequence of integers, then it contains the indices of the
            qubits that are set to one (indexing starts from 0). For
            example, the list [2, 3] represents qubits 2 and 3 being set to one.
            Default is 0, the all zeros state.
    """
    if not occupied_orbitals or isinstance(occupied_orbitals[0], int):
        # Generic
        occupied_orbitals = cast(Sequence[int], occupied_orbitals)
        yield _generic_gaussian_circuit(
                qubits, quadratic_hamiltonian, occupied_orbitals, initial_state)
    else:
        # Spin symmetry
        occupied_orbitals = cast(Tuple[Sequence[int], Sequence[int]],
                                 occupied_orbitals)
        yield _spin_symmetric_gaussian_circuit(
                qubits, quadratic_hamiltonian, occupied_orbitals, initial_state)

def _generic_gaussian_circuit(
        qubits: Sequence[cirq.Qid],
        quadratic_hamiltonian: QuadraticHamiltonian,
        occupied_orbitals: Optional[Sequence[int]],
        initial_state: Union[int, Sequence[int]]) -> cirq.OP_TREE:

    n_qubits = len(qubits)
    circuit_description, start_orbitals = gaussian_state_preparation_circuit(
            quadratic_hamiltonian, occupied_orbitals)

    if isinstance(initial_state, int):
        initially_occupied_orbitals = _occupied_orbitals(
                initial_state, n_qubits)
    else:
        initially_occupied_orbitals = initial_state  # type: ignore

    # Flip bits so that the correct starting orbitals are occupied
    yield (cirq.X(qubits[j]) for j in range(n_qubits)
           if (j in initially_occupied_orbitals) != (j in start_orbitals))

    yield _ops_from_givens_rotations_circuit_description(
            qubits, circuit_description)

def _spin_symmetric_gaussian_circuit(
        qubits: Sequence[cirq.Qid],
        quadratic_hamiltonian: QuadraticHamiltonian,
        occupied_orbitals: Tuple[Sequence[int], Sequence[int]],
        initial_state: Union[int, Sequence[int]]) -> cirq.OP_TREE:

    n_qubits = len(qubits)

    if isinstance(initial_state, int):
        initially_occupied_orbitals = _occupied_orbitals(
                initial_state, n_qubits)
    else:
        initially_occupied_orbitals = initial_state  # type: ignore

    for spin_sector in range(2):
        circuit_description, start_orbitals = (
                gaussian_state_preparation_circuit(
                    quadratic_hamiltonian,
                    occupied_orbitals[spin_sector],
                    spin_sector=spin_sector)
        )

        def index_map(i):
            return i + spin_sector*(n_qubits // 2)
        spin_indices = [index_map(i) for i in range(n_qubits // 2)]
        spin_qubits = [qubits[i] for i in spin_indices]

        # Flip bits so that the correct starting orbitals are occupied
        yield (cirq.X(spin_qubits[j]) for j in range(n_qubits // 2)
               if (index_map(j) in initially_occupied_orbitals)
               != (index_map(j) in [index_map(k) for k in start_orbitals]))

        yield _ops_from_givens_rotations_circuit_description(
                spin_qubits, circuit_description)

def prepare_slater_determinant(qubits: Sequence[cirq.Qid],
                               slater_determinant_matrix: numpy.ndarray,
                               initial_state: Union[int, Sequence[int]]=0
                               ) -> cirq.OP_TREE:
    r"""Prepare a Slater determinant from a computational basis state.

    A Slater determinant is described by an :math:`\eta \times N` matrix
    :math:`Q` with orthonormal rows, where :math:`\eta` is the particle number
    and :math:`N` is the total number of modes. The state corresponding to this
    matrix is

    .. math::

        b^\dagger_1 \cdots b^\dagger_{\eta} \lvert \text{vac} \rangle,

    where

    .. math::

        b^\dagger_j = \sum_{k = 1}^N Q_{jk} a^\dagger_k.

    The algorithm used is described in arXiv:1711.05395. It assumes the
    Jordan-Wigner transform.

    Args:
        qubits: The qubits to which to apply the circuit.
        slater_determinant_matrix: The matrix :math:`Q` which describes the
            Slater determinant to be prepared.
        initial_state: The computational basis state that the qubits start in.
            This can be either an integer or a container of integers.
            If an integer, it is mapped to a computational basis state via
            "big endian" ordering of the binary representation of the integer.
            For example, the computational basis state on five qubits with
            the first and second qubits set to one is 0b11000, which is 24
            in decimal.
            If a container of integers, then it contains the indices of the
            qubits that are set to one (indexing starts from 0). For
            example, the list [2, 3] represents qubits 2 and 3 being set to one.
            Default is 0, the all zeros state.
    """
    n_qubits = len(qubits)
    circuit_description = slater_determinant_preparation_circuit(
            slater_determinant_matrix)
    n_occupied = slater_determinant_matrix.shape[0]

    if isinstance(initial_state, int):
        initially_occupied_orbitals = _occupied_orbitals(
                initial_state, n_qubits)
    else:
        initially_occupied_orbitals = initial_state  # type: ignore

    # Flip bits so that the first n_occupied are 1 and the rest 0
    yield (cirq.X(qubits[j]) for j in range(n_qubits)
           if (j < n_occupied) != (j in initially_occupied_orbitals))

    yield _ops_from_givens_rotations_circuit_description(
            qubits, circuit_description)

def _occupied_orbitals(computational_basis_state: int, n_qubits) -> Set[int]:
    """Indices of ones in the binary expansion of an integer in big endian
    order. e.g. 010110 -> [1, 3, 4]"""
    bitstring = format(computational_basis_state, 'b').zfill(n_qubits)
    return {j for j in range(len(bitstring)) if bitstring[j] == '1'}

def _ops_from_givens_rotations_circuit_description(
        qubits: Sequence[cirq.Qid],
        circuit_description: Iterable[Iterable[
            Union[str, Tuple[int, int, float, float]]]]) -> cirq.OP_TREE:
    """Yield operations from a Givens rotations circuit obtained from
    OpenFermion.
    """
    for parallel_ops in circuit_description:
        for op in parallel_ops:
            if op == 'pht':
                yield cirq.X(qubits[-1])
            else:
                i, j, theta, phi = cast(Tuple[int, int, float, float], op)
                yield Ryxxy(theta).on(qubits[i], qubits[j])
                yield cirq.Z(qubits[j]) ** (phi / numpy.pi)