001/*
002 * This file is part of the JDrupes non-blocking HTTP Codec
003 * Copyright (C) 2016, 2017  Michael N. Lipp
004 *
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Lesser General Public License as published
007 * by the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
013 * License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.httpcodec.protocols.websocket;
020
021/**
022 * The Websocket message header.
023 */
024public class WsMessageHeader extends WsFrameHeader {
025
026        private boolean textMode;
027        private boolean hasPayload;
028
029        /**
030         * Creates a new message header.
031         * 
032         * @param textMode indicates whether the data is sent as text
033         * @param hasPayload indicates that the message has a payload
034         */
035        public WsMessageHeader(boolean textMode, boolean hasPayload) {
036                super();
037                this.textMode = textMode;
038                this.hasPayload = hasPayload;
039        }
040
041        /* (non-Javadoc)
042         * @see org.jdrupes.httpcodec.MessageHeader#isFinal()
043         */
044        @Override
045        public boolean isFinal() {
046                return false;
047        }
048
049        /**
050         * @return whether the data is sent as text
051         */
052        public boolean isTextMode() {
053                return textMode;
054        }
055
056        @Override
057        public boolean hasPayload() {
058                return hasPayload;
059        }
060
061        /* (non-Javadoc)
062         * @see java.lang.Object#toString()
063         */
064        @Override
065        public String toString() {
066                StringBuilder builder = new StringBuilder();
067                builder.append("WsMessageHeader [textMode=");
068                builder.append(textMode);
069                builder.append(", hasPayload=");
070                builder.append(hasPayload);
071                builder.append("]");
072                return builder.toString();
073        }
074        
075}