Package esmska.data

Class Envelope


  • public class Envelope
    extends java.lang.Object
    Class for preparing attributes of sms (single or multiple)
    • Constructor Summary

      Constructors 
      Constructor Description
      Envelope()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)  
      java.util.ArrayList<SMS> generate()
      generate list of sms's to send
      java.util.Set<Contact> getContacts()
      get all recipients
      java.util.ArrayList<java.lang.Integer> getIndicesOfCuts​(java.lang.String msgText, int limit)
      Cut text into pieces while trying to keep word boundaries.
      int getMaxTextLength()
      get maximum length of sendable message.
      int getMaxTextLength​(java.lang.String customText)
      get maximum length of sendable message
      int getPenultimateIndexOfCut​(java.lang.String msgText, int limit)
      If exists penultimate index of cut msgText to SMS pieces, find it, other return 0;
      java.lang.String getSenderName()  
      int getSMSCount​(java.lang.String msgText, int limit)
      Get number of sms pieces cutting from msgText depending on max SMS length limit.
      int getSMSLength()
      get length of one sms
      java.lang.String getText()
      get text of sms
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)  
      void setContacts​(java.util.Set<Contact> contacts)
      set all recipients
      void setText​(java.lang.String text)
      set text of sms
      • Methods inherited from class java.lang.Object

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

      • Envelope

        public Envelope()
    • Method Detail

      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      • getText

        public java.lang.String getText()
        get text of sms
      • setText

        public void setText​(java.lang.String text)
        set text of sms
      • getContacts

        public java.util.Set<Contact> getContacts()
        get all recipients
      • setContacts

        public void setContacts​(java.util.Set<Contact> contacts)
        set all recipients
      • getSenderName

        public java.lang.String getSenderName()
      • getMaxTextLength

        public int getMaxTextLength​(java.lang.String customText)
        get maximum length of sendable message
        Parameters:
        customText - a message text to measure. Because of cutting message by word boundaries, the maximum length varies depending on how the input text is structured.
      • getMaxTextLength

        public int getMaxTextLength()
        get maximum length of sendable message. Uses envelope text to measure it.
      • getSMSLength

        public int getSMSLength()
        get length of one sms
      • getSMSCount

        public int getSMSCount​(java.lang.String msgText,
                               int limit)
        Get number of sms pieces cutting from msgText depending on max SMS length limit. The pieces will be split by word boundaries, unless it would take away more than 10% of the text - in that case it will be split by characters (splitting the word).
        Parameters:
        msgText - full message text
        limit - max SMS length limit
        Returns:
        resulting number of sms cutting from msgText; the number is 0 if @param limit is zero or negative
      • generate

        public java.util.ArrayList<SMS> generate()
        generate list of sms's to send
      • getIndicesOfCuts

        public java.util.ArrayList<java.lang.Integer> getIndicesOfCuts​(java.lang.String msgText,
                                                                       int limit)
        Cut text into pieces while trying to keep word boundaries.
        Parameters:
        msgText - full message text
        limit - max single piece length
        Returns:
        list containing indices of cuts (in ascending order). The list is empty if @param limit is zero or negative.
      • getPenultimateIndexOfCut

        public int getPenultimateIndexOfCut​(java.lang.String msgText,
                                            int limit)
        If exists penultimate index of cut msgText to SMS pieces, find it, other return 0;
        Parameters:
        msgText - full message text
        limit - max length of SMS
        Returns:
        penultimate index of cut or 0