View Javadoc

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
    10   *    http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   *  Unless required by applicable law or agreed to in writing,
    13   *  software distributed under the License is distributed on an
    14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   *  KIND, either express or implied.  See the License for the
    16   *  specific language governing permissions and limitations
    17   *  under the License.
    18   *
    19   */
    20  package org.apache.mina.transport.serial;
    21
    22  import org.apache.mina.core.session.AbstractIoSessionConfig;
    23  import org.apache.mina.core.session.IoSessionConfig;
    24
    25  /**
    26   * The default configuration for a serial session {@link SerialSessionConfig}.
    27   *
    28   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
    29   */
    30  class DefaultSerialSessionConfig extends AbstractIoSessionConfig implements SerialSessionConfig {
    31
    32      private int receiveThreshold = -1;
    33
    34      private int inputBufferSize = 8;
    35
    36      private int outputBufferSize = 8;
    37
    38      private boolean lowLatency = false;
    39
    40      public DefaultSerialSessionConfig() {
    41          // All default properties were configured above.
    42      }
    43
    44      /**
    45       * {@inheritDoc}
    46       */
    47      @Override
    48      protected void doSetAll(IoSessionConfig config) {
    49          if (config instanceof SerialSessionConfig) {
    50              SerialSessionConfig cfg = (SerialSessionConfig) config;
    51              setInputBufferSize(cfg.getInputBufferSize());
    52              setReceiveThreshold(cfg.getReceiveThreshold());
    53          }
    54      }
    55
    56      /**
    57       * {@inheritDoc}
    58       */
    59      public int getInputBufferSize() {
    60          return inputBufferSize;
    61      }
    62
    63      /**
    64       * {@inheritDoc}
    65       */
    66      public boolean isLowLatency() {
    67          return lowLatency;
    68      }
    69
    70      /**
    71       * {@inheritDoc}
    72       */
    73      public void setInputBufferSize(int bufferSize) {
    74          inputBufferSize = bufferSize;
    75      }
    76
    77      /**
    78       * {@inheritDoc}
    79       */
    80      public void setLowLatency(boolean lowLatency) {
    81          this.lowLatency = lowLatency;
    82      }
    83
    84      /**
    85       * {@inheritDoc}
    86       */
    87      public int getReceiveThreshold() {
    88          return receiveThreshold;
    89      }
    90
    91      /**
    92       * {@inheritDoc}
    93       */
    94      public void setReceiveThreshold(int bytes) {
    95          receiveThreshold = bytes;
    96      }
    97
    98      /**
    99       * {@inheritDoc}
    100      */
    101     public int getOutputBufferSize() {
    102         return outputBufferSize;
    103     }
    104
    105     /**
    106      * {@inheritDoc}
    107      */
    108     public void setOutputBufferSize(int bufferSize) {
    109         outputBufferSize = bufferSize;
    110
    111     }
    112 }