Esempio n. 1
0
 /// <summary>
 /// Method to Strip the binary padding from a token
 /// </summary>
 /// <param name="bitPadDir">The bit side that has been compacted</param>
 /// <param name="compaction">The compaction base ie 8bit, 7bit</param>
 /// <param name="token">Token to strip binary padding from</param>
 /// <returns><paramref name="token"/> stripped of all padding</returns>
 private static String StripTokenBinaryPadding(String token, PadDirectionList bitPadDir, int compaction)
 {
     // TODO Buy ISO 15962 and figure out how single char compaction works
     // with RFID this is just a logical port of the java 1.4 FOSSTRAK implementation
     if (compaction >= 4)
     {
         if (bitPadDir == PadDirectionList.RIGHT)
         {
             int lastnonzerobit  = token.LastIndexOf("1");
             int bitsforstripped = compaction * (1 + lastnonzerobit / compaction);
             return(token.Substring(0, bitsforstripped));
         }
         else
         {
             int firstnonzerobit = token.IndexOf("1");
             int length          = token.Length;
             int bitsforstripped = compaction * (1 + (length - firstnonzerobit) / compaction);
             return(token.Substring(length - bitsforstripped));
         }
     }
     else
     {
         if (bitPadDir == PadDirectionList.RIGHT)
         {
             int lastnonzerobit = token.LastIndexOf("1");
             return(token.Substring(0, lastnonzerobit));
         }
         else
         {
             int firstnonzerobit = token.IndexOf("1");
             return(token.Substring(firstnonzerobit));
         }
     }
 }
Esempio n. 2
0
        private String ApplyPadChar(String bare, PadDirectionList dir, String padchar, int requiredLength)
        {
            if (dir == null || padchar == null || requiredLength == -1)
            {
                return(bare);
            }
            else
            {
                StringBuilder buf = new StringBuilder(requiredLength);
                for (int i = 0; i < requiredLength - bare.Length; i++)
                {
                    buf.Append(padchar);
                }

                if (dir == PadDirectionList.RIGHT)
                {
                    return(bare + buf.ToString());
                }
                else
                {
                    // if (dir == PadDirectionList.LEFT)
                    return(buf.ToString() + bare);
                }
            }
        }
Esempio n. 3
0
 private String StripPadChar(String padded, PadDirectionList dir, String padchar)
 {
     if (dir == PadDirectionList.LEFT)
     {
         return(padded.Substring(padded.IndexOf(padchar)));
     }
     else
     {
         return(padded.Substring(0, padded.Length - padded.LastIndexOf(padchar)));
     }
 }
Esempio n. 4
0
 private String StripPadChar(String padded, PadDirectionList dir, String padchar)
 {
     if (dir == PadDirectionList.LEFT)
     {
         return padded.Substring(padded.IndexOf(padchar));
     }
     else
     {
         return padded.Substring(0, padded.Length - padded.LastIndexOf(padchar));
     }
 }
Esempio n. 5
0
        private String ApplyPadChar(String bare, PadDirectionList dir, String padchar, int requiredLength)
        {
            if (dir == null || padchar == null || requiredLength == -1)
            {
                return bare;
            }
            else
            {
                StringBuilder buf = new StringBuilder(requiredLength);
                for (int i = 0; i < requiredLength - bare.Length; i++)
                {
                    buf.Append(padchar);
                }

                if (dir == PadDirectionList.RIGHT)
                    return bare + buf.ToString();
                else
                    // if (dir == PadDirectionList.LEFT)
                    return buf.ToString() + bare;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Method to Strip the binary padding from a token
        /// </summary>
        /// <param name="bitPadDir">The bit side that has been compacted</param>
        /// <param name="compaction">The compaction base ie 8bit, 7bit</param>
        /// <param name="token">Token to strip binary padding from</param>
        /// <returns><paramref name="token"/> stripped of all padding</returns>
        private static String StripTokenBinaryPadding(String token, PadDirectionList bitPadDir, int compaction)
        {
            // TODO Buy ISO 15962 and figure out how single char compaction works
            // with RFID this is just a logical port of the java 1.4 FOSSTRAK implementation
            if (compaction >= 4)
            {
                if (bitPadDir == PadDirectionList.RIGHT)
                {
                    int lastnonzerobit = token.LastIndexOf("1");
                    int bitsforstripped = compaction * (1 + lastnonzerobit / compaction);
                    return token.Substring(0, bitsforstripped);
                }
                else
                {
                    int firstnonzerobit = token.IndexOf("1");
                    int length = token.Length;
                    int bitsforstripped = compaction * (1 + (length - firstnonzerobit) / compaction);
                    return token.Substring(length - bitsforstripped);
                }

            }
            else
            {
                if (bitPadDir == PadDirectionList.RIGHT)
                {
                    int lastnonzerobit = token.LastIndexOf("1");
                    return token.Substring(0, lastnonzerobit);
                }
                else
                {
                    int firstnonzerobit = token.IndexOf("1");
                    return token.Substring(firstnonzerobit);
                }

            }
        }