Returns Incremented position so that position mod align == 0, but doesn't
change channels position.
@param ch
@param align
@return
@throws IOException
544685
public static final long alignedPosition(SeekableByteChannel ch, long align) throws IOException
    {
        long position = ch.position();
        long mod = position % align;
        if (mod > 0)
        {
            return position + align - mod;
        }
        else
        {
            return position;
        }
    }
1018656
public void align(Structure s1, String chainId1, Structure s2,
			String chainId2) throws StructureException {
		align(s1, chainId1, s2, chainId2, params);
	}
1052931
public boolean consume(int ch){
        offset++;
        if(ch==0x0D){
            skipLF = true;
            line++;
            col = 0;
            return true;
        }else if(ch==0x0A){
            if(skipLF){
                skipLF = false;
                return false;
            }else{
                line++;
                col = 0;
                return true;
            }
        }else{
            skipLF = false;
            col++;
            return true;
        }
    }
549733
def align(self, alignment = None):
		
		if alignment is None:
			if self.reader.sysinfo.ProcessorArchitecture == PROCESSOR_ARCHITECTURE.AMD64:
				alignment = 8
			else:
				alignment = 4
		offset = self.current_position % alignment
		if offset == 0:
			return
		offset_to_aligned = (alignment - offset) % alignment
		self.seek(offset_to_aligned, 1)
		return
1324514
public static String alignLeft(Object o, int width, char c) {
        if (null == o)
            return null;
        String s      = o.toString();
        int    length = s.length();
        if (length >= width)
            return s;
        return s + dup(c, width - length);
    }
1186258
public void setDescriptionAlignment(final Pos ALIGNMENT) {
        if (null == descriptionAlignment) {
            _descriptionAlignment = ALIGNMENT;
            fireTileEvent(REDRAW_EVENT);
        } else {
            descriptionAlignment.set(ALIGNMENT);
        }
    }
965536
function setAlign($col_id, $align = self::CONSOLE_TABLE_ALIGN_LEFT) {
        switch ($align) {
            case self::CONSOLE_TABLE_ALIGN_CENTER:
                $pad = STR_PAD_BOTH;
                break;
            case self::CONSOLE_TABLE_ALIGN_RIGHT:
                $pad = STR_PAD_LEFT;
                break;
            default:
                $pad = STR_PAD_RIGHT;
                break;
        }
        $this->_col_align[$col_id] = $pad;
    }
205741
@Override
    public long position() throws IOException
    {
        if (inflater == null && deflater == null)
        {
            return 0;
        }
        if (inflater != null)
        {
            return inflater.getBytesWritten();
        }
        else
        {
            return deflater.getBytesRead();
        }
    }
472711
public static long align(final long value, final int alignment) {
        if (!isPowerOfTwo(alignment)) {
            throw new IllegalArgumentException("alignment must be a power of 2:" + alignment);
        }
        return (value + (alignment - 1)) & ~(alignment - 1);
    }
533459
public int alignBox(Inline box)
    {
    	if (box instanceof InlineElement)
    	{
	        VerticalAlign va = ((InlineElement) box).getVerticalAlign();
	        if (va == VerticalAlign.TOP || va == VerticalAlign.BOTTOM)
	        {
	            return 0; //top and bottom boxes are aligned to the line box in their absolutePositions()
	        }
	        else
	        {
	            return above + computeBaselineDifference((InlineElement) box) - box.getBaselineOffset() + ((InlineElement) box).getLineboxOffset();
	        }
    	}
    	else
    		return above - box.getBaselineOffset();
    }
586582
def align(offset, alignment):
    
    if offset % alignment == 0:
        return offset
    return offset + (alignment - (offset % alignment))
62698
public void align() throws IOException {
		if (capacity < BITS_IN_BYTE) {
			ostream.write(buffer << capacity);
			capacity = BITS_IN_BYTE;
			buffer = 0;
			len++;
		}
	}
1119158
public void append(final char ch) {
        final int newlen = this.len + 1;
        if (newlen > this.array.length) {
            expand(newlen);
        }
        this.array[this.len] = ch;
        this.len = newlen;
    }
1005606
public void setAlign(String align) throws ApplicationException {
	align = StringUtil.toLowerCase(align);
	if (align.equals("left")) this.align = Table.ALIGN_LEFT;
	else if (align.equals("center")) this.align = Table.ALIGN_CENTER;
	else if (align.equals("right")) this.align = Table.ALIGN_RIGHT;
	else throw new ApplicationException("value [" + align + "] of attribute align from tag col is invalid", "valid values are [left, center, right]");
    }
1319123
public UnicodeMatcher lookupMatcher(int ch) {
        UnicodeSet retVal = null;
        if (ch == 0xffff) {
            retVal = fCachedSetLookup;
            fCachedSetLookup = null;
        }
        return retVal;
    }
196711
private int next(int ch) throws IOException {
    // TODO: try my own form of indirect jump... look up char class and index directly into handling implementation?
    for(;;) {
      switch (ch) {
        case ' ': // this is not the exclusive list of whitespace chars... the rest are handled in default:
        case '\t':
        case '\r':
        case '\n':
          ch = getCharNWS(); // calling getCharNWS here seems faster than letting the switch handle it
          break;
        case '"' :
          stringTerm = '"';
          valstate = STRING;
          return STRING;
        case '\'' :
          if ((flags & ALLOW_SINGLE_QUOTES) == 0) {
            throw err("Single quoted strings not allowed");
          }
          stringTerm = '\'';
          valstate = STRING;
          return STRING;
        case '{' :
          push();
          state= DID_OBJSTART;
          return OBJECT_START;
        case '[':
          push();
          state=DID_ARRSTART;
          return ARRAY_START;
        case '0' :
          out.reset();
          //special case '0'?  If next char isn't '.' val=0
          ch=getChar();
          if (ch=='.') {
            start--; ch='0';
            readNumber('0',false);
            return valstate;
          } else if (ch>'9' || ch<'0') {
            out.unsafeWrite('0');
            if (ch!=-1) start--;
            lval = 0;
            valstate=LONG;
            return LONG;
          } else {
            throw err("Leading zeros not allowed");
          }
        case '1' :
        case '2' :
        case '3' :
        case '4' :
        case '5' :
        case '6' :
        case '7' :
        case '8' :
        case '9' :
          out.reset();
          lval = readNumber(ch,false);
          return valstate;
        case '-' :
          out.reset();
          out.unsafeWrite('-');
          ch = getChar();
          if (ch<'0' || ch>'9') throw err("expected digit after '-'");
          lval = readNumber(ch,true);
          return valstate;
        case 't':
          // TODO: test performance of this non-branching inline version.
          // if ((('r'-getChar())|('u'-getChar())|('e'-getChar())) != 0) throw err("");
          if (matchBareWord(JSONUtil.TRUE_CHARS)) {
            bool = true;
            valstate = BOOLEAN;
            return valstate;
          } else {
            valstate = STRING;
            return STRING;
          }
        case 'f':
          if (matchBareWord(JSONUtil.FALSE_CHARS)) {
            bool = false;
            valstate = BOOLEAN;
            return valstate;
          } else {
            valstate = STRING;
            return STRING;
          }
        case 'n':
          if (matchBareWord(JSONUtil.NULL_CHARS)) {
            valstate = NULL;
            return valstate;
          } else {
            valstate = STRING;
            return STRING;
          }
        case '/':
          getSlashComment();
          ch = getChar();
          break;
        case '#':
          getNewlineComment();
          ch = getChar();
          break;
        case ']':  // This only happens with a trailing comma (or an error)
          if (state != DID_ARRELEM || (flags & ALLOW_EXTRA_COMMAS)==0) {
            throw err("Unexpected array closer ]");
          }
          pop();
          return event = ARRAY_END;
        case '}':  // This only happens with a trailing comma (or an error)
          if (state != DID_MEMVAL || (flags & ALLOW_EXTRA_COMMAS)==0) {
            throw err("Unexpected object closer }");
          }
          pop();
          return event = ARRAY_END;
        case ',': // This only happens with input like [1,]
          if ((state != DID_ARRELEM && state != DID_MEMVAL) || (flags & ALLOW_EXTRA_COMMAS)==0) {
            throw err("Unexpected comma");
          }
          ch = getChar();
          break;
        case -1:
          if (getLevel()>0) throw err("Premature EOF");
          return EOF;
        default:
          // Handle unusual unicode whitespace like no-break space (0xA0)
          if (isWhitespace(ch)) {
            ch = getChar();  // getCharNWS() would also work
            break;
          }
          handleNonDoubleQuoteString(ch, false);
          valstate = STRING;
          return STRING;
          // throw err(null);
      }

    }
  }
107978
private final void alignBuffer(final int diff) throws IOException {
		if (bufOutput.remaining() < diff) {
			flushBuffer();
		}
		bufOutput.put(MAGIC_PADDING); // Magic for Padding
		int i = 1;
		for (; i + 8 <= diff; i += 8) {
			bufOutput.putLong(0L);
		}
		for (; i + 4 <= diff; i += 4) {
			bufOutput.putInt(0);
		}
		switch (diff - i) {
			case 3:
				bufOutput.put((byte) 0);
			case 2:
				bufOutput.putShort((short) 0);
				break;
			case 1:
				bufOutput.put((byte) 0);
		}
	}