/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/SelectorKeyImpl.java

http://mobicents.googlecode.com/ · Java · 86 lines · 40 code · 17 blank · 29 comment · 0 complexity · 54b98de7dfb86b653cfd2d66cb1c023d MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. /*
  23. * To change this template, choose Tools | Templates
  24. * and open the template in the editor.
  25. */
  26. package org.mobicents.ss7.hardware.dahdi;
  27. import org.mobicents.protocols.stream.api.SelectorKey;
  28. import org.mobicents.protocols.stream.api.Stream;
  29. import org.mobicents.protocols.stream.api.StreamSelector;
  30. /**
  31. *
  32. * @author kulikov
  33. */
  34. public class SelectorKeyImpl implements SelectorKey {
  35. private boolean isValid;
  36. private boolean isReadable;
  37. private boolean isWritable;
  38. private Channel channel;
  39. private Selector selector;
  40. private Object attachment;
  41. protected SelectorKeyImpl(Channel channel, Selector selector) {
  42. this.channel = channel;
  43. this.selector = selector;
  44. }
  45. public boolean isValid() {
  46. throw new UnsupportedOperationException("Not supported yet.");
  47. }
  48. public boolean isReadable() {
  49. return isReadable;
  50. }
  51. public boolean isWriteable() {
  52. return isWritable;
  53. }
  54. public Stream getStream() {
  55. return channel;
  56. }
  57. public StreamSelector getStreamSelector() {
  58. return selector;
  59. }
  60. public void cancel() {
  61. selector.unregister(channel);
  62. }
  63. public void attach(Object obj) {
  64. this.attachment = obj;
  65. }
  66. public Object attachment() {
  67. return this.attachment;
  68. }
  69. }