Extension to CommAPI This is an extension to CommAPI. It may not be
supported on all operating systems.

@return int the End of Input Character
@throws UnsupportedCommOperationException on error Anyone know how to do
this in Unix?
170485
@Override
    public byte getEndOfInputChar() throws UnsupportedCommOperationException {
        byte ret;

        logger.fine("getEndOfInputChar()");
        ret = nativeGetEndOfInputChar();

        logger.fine("getEndOfInputChar() returns " + ret);
        return (ret);
    }
446715
public function getMaximalDistance()
    {
        $oneSize = mb_strlen($this->compOne, 'UTF-8');
        $twoSize = mb_strlen($this->compTwo, 'UTF-8');

        // Is substitution cheaper that delete + insert?
        $subCost = min($this->subCost, $this->delCost + $this->insCost);

        // Get common size
        $minSize = min($oneSize, $twoSize);
        $maxSize = max($oneSize, $twoSize);
        $extraSize = $maxSize - $minSize;

        // On common size perform substitution / delete + insert, what is cheaper
        $maxCost = $subCost * $minSize;

        // On resulting do insert/delete
        if ($oneSize > $twoSize) {
            // Delete extra characters
            $maxCost += $extraSize * $this->delCost;
        } else {
            // Insert extra characters
            $maxCost += $extraSize * $this->insCost;
        }

        return $maxCost;
    }
732865
@Override
  public long length() {
    //The length of a character string is the number of UTF-16 units (not the number of characters)
    long len = 0;
    int pos = offset;

    //set ASCII (<= 127 chars)
    for (; len < length && data[pos] >= 0; ) {
      len++;
      pos++;
    }

    //multi-bytes UTF-8
    while (pos < offset + length) {
      byte firstByte = data[pos++];
      if (firstByte < 0) {
        if (firstByte >> 5 != -2 || (firstByte & 30) == 0) {
          if (firstByte >> 4 == -2) {
            if (pos + 1 < offset + length) {
              pos += 2;
              len++;
            } else {
              throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
            }
          } else if (firstByte >> 3 != -2) {
            throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
          } else if (pos + 2 < offset + length) {
            pos += 3;
            len += 2;
          } else {
            //bad truncated UTF8
            pos += offset + length;
            len += 1;
          }
        } else {
          pos++;
          len++;
        }
      } else {
        len++;
      }
    }
    return len;
  }
147114
public function peekToEnd()
    {
        return substr($this->string, $this->scanOffset, strlen($this->string) - $this->scanOffset);        
    }
224048
private int resolveCharEnt(StringBuffer originalCharacters)
        throws XMLStreamException
    {
        int value = 0;
        char c = getNextChar(SUFFIX_IN_ENTITY_REF);
        
        if (originalCharacters != null) {
            originalCharacters.append(c);
        }
        
        if (c == 'x') { // hex
            while (true) {
                c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
                    : getNextCharFromCurrent(SUFFIX_IN_ENTITY_REF);
                if (c == ';') {
                    break;
                }
                
                if (originalCharacters != null) {
                    originalCharacters.append(c);
                }
                value = value << 4;
                if (c <= '9' && c >= '0') {
                    value += (c - '0');
                } else if (c >= 'a' && c <= 'f') {
                    value += 10 + (c - 'a');
                } else if (c >= 'A' && c <= 'F') {
                    value += 10 + (c - 'A');
                } else {
                    throwUnexpectedChar(c, "; expected a hex digit (0-9a-fA-F).");
                }
                // Overflow?
                if (value > MAX_UNICODE_CHAR) {
                    reportUnicodeOverflow();
                }
            }
        } else { // numeric (decimal)
            while (c != ';') {
                if (c <= '9' && c >= '0') {
                    value = (value * 10) + (c - '0');
                    // Overflow?
                    if (value > MAX_UNICODE_CHAR) {
                        reportUnicodeOverflow();
                    }
                } else {
                    throwUnexpectedChar(c, "; expected a decimal number.");
                }
                c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
                    : getNextCharFromCurrent(SUFFIX_IN_ENTITY_REF);
                
                if (originalCharacters != null && c != ';') {
                    originalCharacters.append(c);
                }
            }
        }
        validateChar(value);
        return value;
    }
1227869
private function getEndianess()
    {
        if (0 === self::$endianess) {
            self::$endianess = $this->fromInt32("\x01\x00\x00\x00") == 1
                             ? self::LITTLE_ENDIAN_ORDER
                             : self::BIG_ENDIAN_ORDER;
        }
        return self::$endianess;
    }
500792
public function getIntegerPart()
	{
		if ( ! $this->getIsDecimal() ) return $this->_value;
		return substr( $this->_value, 0, strpos( $this->_value, "." ) );
	}
136895
public function getExtension() {
		$dotPos = strrpos($this->path, '.');
		
		if ($dotPos === false) {
			return;
		}
		
		return substr($this->path, $dotPos + 1);
	}
257586
public function getCondensed()
    {
        if ($this->version === 4) {
            return $this->value;
        }

        $addr = preg_replace('/(^|:)0+(\d)/', '\1\2', $this->getExpanded());

        if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $addr, $matches, PREG_OFFSET_CAPTURE)) {
            $max = 0;
            $pos = null;

            foreach ($matches[0] as $match) {
                if (strlen($match[0]) > $max) {
                    $max = mb_strlen($match[0]);
                    $pos = $match[1];
                }
            }

            $addr = substr_replace($addr, '::', $pos, $max);
        }

        return $addr;
    }
1100585
private int utf8Position(int charPosition) {
    int pos = offset;
    for (int i = 0; i < charPosition; i++) {
      int byteValue = data[pos] & 0xff;
      if (byteValue < 0x80) {
        pos += 1;
      } else if (byteValue < 0xC2) {
        throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
      } else if (byteValue < 0xE0) {
        pos += 2;
      } else if (byteValue < 0xF0) {
        pos += 3;
      } else if (byteValue < 0xF8) {
        pos += 4;
      } else {
        throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
      }
    }
    return pos;
  }
118436
public static int indexOfControlOrNonAscii(String input) {
    for (int i = 0, length = input.length(); i < length; i++) {
      char c = input.charAt(i);
      if (c <= '\u001f' || c >= '\u007f') {
        return i;
      }
    }
    return -1;
  }
1020441
int encodeCEs(long ces[], int cesLength) {
        if(cesLength < 0 || cesLength > Collation.MAX_EXPANSION_LENGTH) {
            throw new IllegalArgumentException("mapping to too many CEs");
        }
        if(!isMutable()) {
            throw new IllegalStateException("attempt to add mappings after build()");
        }
        if(cesLength == 0) {
            // Convenience: We cannot map to nothing, but we can map to a completely ignorable CE.
            // Do this here so that callers need not do it.
            return encodeOneCEAsCE32(0);
        } else if(cesLength == 1) {
            return encodeOneCE(ces[0]);
        } else if(cesLength == 2) {
            // Try to encode two CEs as one CE32.
            long ce0 = ces[0];
            long ce1 = ces[1];
            long p0 = ce0 >>> 32;
            if((ce0 & 0xffffffffff00ffL) == Collation.COMMON_SECONDARY_CE &&
                    (ce1 & 0xffffffff00ffffffL) == Collation.COMMON_TERTIARY_CE &&
                    p0 != 0) {
                // Latin mini expansion
                return
                    (int)p0 |
                    (((int)ce0 & 0xff00) << 8) |
                    (((int)ce1 >> 16) & 0xff00) |
                    Collation.SPECIAL_CE32_LOW_BYTE |
                    Collation.LATIN_EXPANSION_TAG;
            }
        }
        // Try to encode two or more CEs as CE32s.
        int[] newCE32s = new int[Collation.MAX_EXPANSION_LENGTH];  // TODO: instance field?
        for(int i = 0;; ++i) {
            if(i == cesLength) {
                return encodeExpansion32(newCE32s, 0, cesLength);
            }
            int ce32 = encodeOneCEAsCE32(ces[i]);
            if(ce32 == Collation.NO_CE32) { break; }
            newCE32s[i] = ce32;
        }
        return encodeExpansion(ces, 0, cesLength);
    }
1050594
public static String unexpand(CharSequence self, int tabStop) {
        String s = self.toString();
        if (s.length() == 0) return s;
        try {
            StringBuilder builder = new StringBuilder();
            for (String line : readLines((CharSequence) s)) {
                builder.append(unexpandLine(line, tabStop));
                builder.append("\n");
            }
            // remove the normalized ending line ending if it was not present
            if (!s.endsWith("\n")) {
                builder.deleteCharAt(builder.length() - 1);
            }
            return builder.toString();
        } catch (IOException e) {
            /* ignore */
        }
        return s;
    }
526404
private function _get_file_extension()
    {

        if (empty($this->u_mime_type)) return false;

        $tmp                  = explode('/', $this->u_mime_type);
        $this->file_extension = array_pop($tmp);

        unset($tmp);

        return true;
    }
1168029
@Override
   public CursorPosition getCursor()
   {
      if (settings.isAnsiConsole() && Config.isOSPOSIXCompatible())
      {
         try
         {
            StringBuilder col = new StringBuilder(4);
            StringBuilder row = new StringBuilder(4);
            out().print(ANSI.CURSOR_ROW);
            out().flush();
            boolean gotSep = false;
            // read the position
            int[] input = read();

            for (int i = 2; i < input.length - 1; i++)
            {
               if (input[i] == 59) // we got a ';' which is the separator
                  gotSep = true;
               else
               {
                  if (gotSep)
                     col.append((char) input[i]);
                  else
                     row.append((char) input[i]);
               }
            }
            return new CursorPosition(Integer.parseInt(row.toString()),
                     Integer.parseInt(col.toString()));
         }
         catch (Exception e)
         {
            if (settings.isLogging())
               logger.log(Level.SEVERE,
                        "Failed to find current row with ansi code: ", e);
            return new CursorPosition(-1, -1);
         }
      }
      return new CursorPosition(-1, -1);
   }
706109
public String getStringOutput(String appenderName, String encoding) throws UnsupportedEncodingException {
		AdminToolLog4j2OutputStream baos = outputStreams.get(appenderName);
		String output = "";
		if (null != baos) {
			output = baos.getAndReset(encoding);
		}
		return output.trim().isEmpty() ? null : output;
		
	}
1195374
public function getSupportedCharsets()
    {
        if ($this->supportedCharsets === null) {
            $supportedCharsets = [];
            $rs = $this->executeQuery('SHOW CHARACTER SET');
            while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) {
                if (!isset($row['Charset']) || !isset($row['Default collation'])) {
                    throw new Exception(t('Unrecognized result of the "%s" database query.', 'SHOW CHARACTER SET'));
                }
                $supportedCharsets[strtolower($row['Charset'])] = strtolower($row['Default collation']);
            }
            $this->supportedCharsets = $supportedCharsets;
        }

        return $this->supportedCharsets;
    }