Package com.opensymphony.module.sitemesh.html.util

Source Code of com.opensymphony.module.sitemesh.html.util.StringSitemeshBuffer

package com.opensymphony.module.sitemesh.html.util;

import com.opensymphony.module.sitemesh.SitemeshBuffer;
import com.opensymphony.module.sitemesh.SitemeshBufferFragment;

import java.io.IOException;
import java.io.Writer;

/**
* SitemeshBuffer that is a string
*/
public class StringSitemeshBuffer implements SitemeshBuffer {
    private final String buffer;

    public StringSitemeshBuffer(String buffer) {
        this.buffer = buffer;
    }

    public char[] getCharArray() {
        return buffer.toCharArray();
    }

    public int getBufferLength() {
        return buffer.length();
    }

    public int getTotalLength() {
        return buffer.length();
    }

    public int getTotalLength(int start, int length) {
        return length;
    }

    public void writeTo(Writer writer, int start, int length) throws IOException {
        writer.write(buffer, start, length);
    }

    public boolean hasFragments() {
        return false;
    }

    public static SitemeshBufferFragment createBufferFragment(String buffer)
    {
        return new SitemeshBufferFragment(new StringSitemeshBuffer(buffer), 0, buffer.length());
    }

}
TOP

Related Classes of com.opensymphony.module.sitemesh.html.util.StringSitemeshBuffer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.