Android Open Source - MConsole Attributed Block






From Project

Back to project page MConsole.

License

The source code is released under:

MIT License

If you think the Android project MConsole 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

package pl.skifo.mconsole;
//  w ww. j  av  a2  s.  c o m
import java.util.ArrayList;

public class AttributedBlock {

    public static final AttributedBlock EMPTY_BLOCK = new AttributedBlock();  
     
    
    
    private AttributedLine[] lines;
    
    public AttributedBlock(ArrayList<AttributedLine> lineList) {
        lines = new AttributedLine[lineList.size()]; 
        lines = lineList.toArray(lines);
    }

    public AttributedBlock() {
        lines = new AttributedLine[0]; 
    }

    public AttributedBlock(String line, int color) {
        lines = new AttributedLine[1];
        lines[0] = new AttributedLine(line, color);
    }

    public AttributedBlock(String line) {
        this(line, AttributedString.DEFAULT_COLOR); 
    }
    
    public AttributedLine[] getLines() {
        return lines;
    }
    
    public String toString() {
        StringBuilder out = new StringBuilder();
        int i = 0;
        for (; i < (lines.length - 1); i++) {
            out.append(lines[i]);
            out.append("\n");
        }
        if (lines.length > 0)
            out.append(lines[i]);
        return out.toString();
    }

    
    public static AttributedBlock createAttributedBlock(byte[] buff, int cnt) {
        ArrayList<AttributedLine> block = new ArrayList<AttributedLine>(); 
        int idx = 0;
        int i = 0;
        for (; i < cnt; i++) { // tokenize
            if ((buff[i] & 0xff) == 0x0a) {
                AttributedLine line = AttributedLine.createAttributedLine(buff, idx, (i - idx));
                block.add(line);
                idx = i + 1;
            }
        }
        if (idx < i) {
            AttributedLine line = AttributedLine.createAttributedLine(buff, idx, (i - idx));
            block.add(line);
        }
        return new AttributedBlock(block);
    }
    
}




Java Source Code List

pl.skifo.mconsole.AttributedBlock.java
pl.skifo.mconsole.AttributedLine.java
pl.skifo.mconsole.AttributedString.java
pl.skifo.mconsole.BanlistDialog.java
pl.skifo.mconsole.CommandPrompt.java
pl.skifo.mconsole.CommandResponseEvaluator.java
pl.skifo.mconsole.CommandSet.java
pl.skifo.mconsole.ConfirmDialog.java
pl.skifo.mconsole.ConsoleOutputImpl.java
pl.skifo.mconsole.ConsoleOutput.java
pl.skifo.mconsole.MConsoleActivity.java
pl.skifo.mconsole.MinecraftColorScheme.java
pl.skifo.mconsole.PlayerActionTp.java
pl.skifo.mconsole.PlayerAdminBan.java
pl.skifo.mconsole.PlayerAdminMode.java
pl.skifo.mconsole.PlayerListAdapter.java
pl.skifo.mconsole.PlayersFragment.java
pl.skifo.mconsole.ResponseEvaluator.java
pl.skifo.mconsole.ResponseReceiver.java
pl.skifo.mconsole.ResponseToastGenerator.java
pl.skifo.mconsole.SayDialog.java
pl.skifo.mconsole.ServerConnector.java
pl.skifo.mconsole.ServerConsoleFragment.java
pl.skifo.mconsole.ServerConsole.java
pl.skifo.mconsole.ServerFragment.java
pl.skifo.mconsole.ServerInfo.java
pl.skifo.mconsole.ServerResponse.java
pl.skifo.mconsole.SimpleToastResponseReceiver.java
pl.skifo.mconsole.TabsPagerAdapter.java
pl.skifo.mconsole.TellDialog.java
pl.skifo.mconsole.TimeSetDialog.java
pl.skifo.mconsole.UserActionDialog.java
pl.skifo.mconsole.UserAdminDialog.java