001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.activemq.command;
018    
019    import org.apache.activemq.state.CommandVisitor;
020    
021    /**
022     * Represents a partial command; a large command that has been split up into
023     * pieces.
024     * 
025     * @openwire:marshaller code="60"
026     * 
027     */
028    public class PartialCommand implements Command {
029    
030        public static final byte DATA_STRUCTURE_TYPE = CommandTypes.PARTIAL_COMMAND;
031    
032        private int commandId;
033        private byte[] data;
034    
035        private transient Endpoint from;
036        private transient Endpoint to;
037    
038        public PartialCommand() {
039        }
040    
041        public byte getDataStructureType() {
042            return DATA_STRUCTURE_TYPE;
043        }
044    
045        /**
046         * @openwire:property version=1
047         */
048        public int getCommandId() {
049            return commandId;
050        }
051    
052        public void setCommandId(int commandId) {
053            this.commandId = commandId;
054        }
055    
056        /**
057         * The data for this part of the command
058         * 
059         * @openwire:property version=1 mandatory=true
060         */
061        public byte[] getData() {
062            return data;
063        }
064    
065        public void setData(byte[] data) {
066            this.data = data;
067        }
068    
069        public Endpoint getFrom() {
070            return from;
071        }
072    
073        public void setFrom(Endpoint from) {
074            this.from = from;
075        }
076    
077        public Endpoint getTo() {
078            return to;
079        }
080    
081        public void setTo(Endpoint to) {
082            this.to = to;
083        }
084    
085        public Response visit(CommandVisitor visitor) throws Exception {
086            throw new IllegalStateException("The transport layer should filter out PartialCommand instances but received: " + this);
087        }
088    
089        public boolean isResponseRequired() {
090            return false;
091        }
092    
093        public boolean isResponse() {
094            return false;
095        }
096    
097        public boolean isBrokerInfo() {
098            return false;
099        }
100    
101        public boolean isMessageDispatch() {
102            return false;
103        }
104    
105        public boolean isMessage() {
106            return false;
107        }
108    
109        public boolean isMessageAck() {
110            return false;
111        }
112    
113        public boolean isMessageDispatchNotification() {
114            return false;
115        }
116    
117        public boolean isShutdownInfo() {
118            return false;
119        }
120        
121        public boolean isConnectionControl() {
122            return false;
123        }
124    
125        public void setResponseRequired(boolean responseRequired) {
126        }
127    
128        public boolean isWireFormatInfo() {
129            return false;
130        }
131    
132        public boolean isMarshallAware() {
133            return false;
134        }
135    
136        public String toString() {
137            int size = 0;
138            if (data != null) {
139                size = data.length;
140            }
141            return "PartialCommand[id: " + commandId + " data: " + size + " byte(s)]";
142        }   
143        
144    }