Class AbstractTransport

java.lang.Object
org.cometd.common.AbstractTransport
All Implemented Interfaces:
org.cometd.bayeux.Transport

public class AbstractTransport
extends java.lang.Object
implements org.cometd.bayeux.Transport
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected AbstractTransport​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> options)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getName()  
    java.lang.Object getOption​(java.lang.String name)
    Returns an option value for the given option name, searching the option name tree.
    boolean getOption​(java.lang.String option, boolean dftValue)
    Get option or default value.
    int getOption​(java.lang.String option, int dftValue)
    Get option or default value.
    long getOption​(java.lang.String option, long dftValue)
    Get option or default value.
    java.lang.String getOption​(java.lang.String option, java.lang.String dftValue)
    Get option or default value.
    java.util.Set<java.lang.String> getOptionNames()  
    java.lang.String getOptionPrefix()  
    void setOption​(java.lang.String name, java.lang.Object value)
    Sets the option value with the given name.
    void setOptionPrefix​(java.lang.String prefix)
    Set the option name prefix segment.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractTransport

      protected AbstractTransport​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.Object> options)
  • Method Details

    • getName

      public java.lang.String getName()
      Specified by:
      getName in interface org.cometd.bayeux.Transport
    • getOption

      public java.lang.Object getOption​(java.lang.String name)
      Returns an option value for the given option name, searching the option name tree. The option map is searched for the option name with the most specific prefix. If this transport was initialized with a call to:
         setOptionPrefix("long-polling.jsonp");
       
      then a call to getOption("foobar") will look for the most specific value with names:
         long-polling.json.foobar
         long-polling.foobar
         foobar
       
      Specified by:
      getOption in interface org.cometd.bayeux.Transport
      Parameters:
      name - the option name to return the value for.
    • setOption

      public void setOption​(java.lang.String name, java.lang.Object value)
      Sets the option value with the given name. The option name is inspected to see whether it starts with the option prefix; if it does not, the option prefix is prepended to the given name.
      Parameters:
      name - the option name to set the value for.
      value - the value of the option.
    • getOptionPrefix

      public java.lang.String getOptionPrefix()
      Specified by:
      getOptionPrefix in interface org.cometd.bayeux.Transport
    • setOptionPrefix

      public void setOptionPrefix​(java.lang.String prefix)
      Set the option name prefix segment.

      Normally this is called by the super class constructors to establish a naming hierarchy for options and iteracts with the setOption(String, Object) method to create a naming hierarchy for options. For example the following sequence of calls:

         setOption("foo","x");
         setOption("bar","y");
         setOptionPrefix("long-polling");
         setOption("foo","z");
         setOption("whiz","p");
         setOptionPrefix("long-polling.jsonp");
         setOption("bang","q");
         setOption("bar","r");
       
      will establish the following option names and values:
         foo: x
         bar: y
         long-polling.foo: z
         long-polling.whiz: p
         long-polling.jsonp.bang: q
         long-polling.jsonp.bar: r
       
      The various getOption(String) methods will search this name tree for the most specific match.
      Parameters:
      prefix - the prefix name
      Throws:
      java.lang.IllegalArgumentException - if the new prefix is not prefixed by the old prefix.
    • getOptionNames

      public java.util.Set<java.lang.String> getOptionNames()
      Specified by:
      getOptionNames in interface org.cometd.bayeux.Transport
    • getOption

      public java.lang.String getOption​(java.lang.String option, java.lang.String dftValue)
      Get option or default value.
      Parameters:
      option - The option name.
      dftValue - The default value.
      Returns:
      option or default value
      See Also:
      getOption(String)
    • getOption

      public long getOption​(java.lang.String option, long dftValue)
      Get option or default value.
      Parameters:
      option - The option name.
      dftValue - The default value.
      Returns:
      option or default value
      See Also:
      getOption(String)
    • getOption

      public int getOption​(java.lang.String option, int dftValue)
      Get option or default value.
      Parameters:
      option - The option name.
      dftValue - The default value.
      Returns:
      option or default value
      See Also:
      getOption(String)
    • getOption

      public boolean getOption​(java.lang.String option, boolean dftValue)
      Get option or default value.
      Parameters:
      option - The option name.
      dftValue - The default value.
      Returns:
      option or default value
      See Also:
      getOption(String)