Android Open Source - Soutils Soutils Message






From Project

Back to project page Soutils.

License

The source code is released under:

MIT License

If you think the Android project Soutils listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* The MIT License (MIT)
//from  w w  w .  j  av  a2 s.  c  o m
Copyright (c) 2012 Jerome Wagener

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/

package com.jeromewagener.soutils.messaging;

/** A simple message representation with a type, sender and content. A message can contain a trowable */
public class SoutilsMessage {
  /** The sender address for internal messages */
  public static final String INTERNAL = "127.0.0.1";
  
  /** The message type */
  private final MessageType type;
  /** The IP address of the message sender */
  private String senderAddress = null;
  /** The actual content of the message */
  private String content = null;
  /** A throwable in case an error occurred */
  private Throwable throwable;
  
  /** Creates a message instance based on the supplied parameters
   * @param type the type of the message
   * @param senderAddress the IP address of the message sender
   * @param content the actual content of the message */
  public SoutilsMessage(MessageType type, String senderAddress, String content) {
    this.type = type;
    this.senderAddress = senderAddress;
    this.content = content;
  }
  
  /** Creates a message instance based on the supplied parameters
   * @param type the type of the message
   * @param senderAddress the IP address of the message sender
   * @param content the actual content of the message
   * @param throwable a throwable in case an exception needs to be attached to the message */
  public SoutilsMessage(MessageType type, String senderAddress, Throwable throwable) {
    this.type = type;
    this.senderAddress = senderAddress;
    this.content = throwable.getMessage();
    this.throwable = throwable;
  }
  
  /** Returns the sender address */
  public String getSenderAddress() {
    return senderAddress;
  }
  
  /** Returns the message content */
  public String getContent() {
    return content;
  }

  /** Returns the message type */
  public MessageType getMessageType() {
    return type;
  }

  /** Returns a throwable in case an exception has been attached to the message */
  public Throwable getThrowable() {
    return throwable;
  }
}




Java Source Code List

com.jeromewagener.soutils.Parameters.java
com.jeromewagener.soutils.android.demo.ActivityHelpers.java
com.jeromewagener.soutils.android.demo.DemoActivity.java
com.jeromewagener.soutils.beaconing.BeaconReceiver.java
com.jeromewagener.soutils.beaconing.BeaconSenderAndReceiver.java
com.jeromewagener.soutils.beaconing.BeaconSender.java
com.jeromewagener.soutils.beaconing.package-info.java
com.jeromewagener.soutils.communication.CommunicationException.java
com.jeromewagener.soutils.communication.CommunicationManager.java
com.jeromewagener.soutils.communication.Communication.java
com.jeromewagener.soutils.communication.package-info.java
com.jeromewagener.soutils.demo.desktop.DemoApp.java
com.jeromewagener.soutils.demo.desktop.DemoHelper.java
com.jeromewagener.soutils.filetransfer.FileTransferClient.java
com.jeromewagener.soutils.filetransfer.FileTransferServer.java
com.jeromewagener.soutils.filetransfer.package-info.java
com.jeromewagener.soutils.messaging.MessageType.java
com.jeromewagener.soutils.messaging.SoutilsMessage.java
com.jeromewagener.soutils.messaging.SoutilsObservable.java
com.jeromewagener.soutils.messaging.SoutilsObserver.java
com.jeromewagener.soutils.messaging.package-info.java
com.jeromewagener.soutils.utilities.InetAddressUtilities.java
com.jeromewagener.soutils.utilities.Soutilities.java
com.jeromewagener.soutils.utilities.package-info.java
com.jeromewagener.soutils.package-info.java