/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.io.IOException
 *  java.io.Writer
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.StringBuffer
 *  java.lang.UnsupportedOperationException
 *  java.util.HashMap
 *  java.util.Map
 *  java.util.Map$Entry
 *  java.util.Set
 *  java.util.StringTokenizer
 */
package org.dom4j.tree;

import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.dom4j.Element;
import org.dom4j.ProcessingInstruction;
import org.dom4j.Visitor;
import org.dom4j.tree.AbstractNode;

public abstract class AbstractProcessingInstruction
extends AbstractNode
implements ProcessingInstruction {
    private String getName(StringTokenizer stringTokenizer) {
        String string2;
        StringBuffer stringBuffer = new StringBuffer(stringTokenizer.nextToken());
        while (stringTokenizer.hasMoreTokens() && !(string2 = stringTokenizer.nextToken()).equals((Object)"=")) {
            stringBuffer.append(string2);
        }
        return stringBuffer.toString().trim();
    }

    private String getValue(StringTokenizer stringTokenizer) {
        String string2;
        String string3 = stringTokenizer.nextToken();
        StringBuffer stringBuffer = new StringBuffer();
        while (stringTokenizer.hasMoreTokens() && !string3.equals((Object)"'") && !string3.equals((Object)"\"")) {
            string3 = stringTokenizer.nextToken();
        }
        String string4 = string3;
        while (stringTokenizer.hasMoreTokens() && !string4.equals((Object)(string2 = stringTokenizer.nextToken()))) {
            stringBuffer.append(string2);
        }
        return stringBuffer.toString();
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visit((ProcessingInstruction)this);
    }

    @Override
    public String asXML() {
        return new StringBuffer().append("<?").append(this.getName()).append(" ").append(this.getText()).append("?>").toString();
    }

    @Override
    public String getName() {
        return this.getTarget();
    }

    @Override
    public short getNodeType() {
        return 7;
    }

    @Override
    public String getPath(Element element) {
        Element element2 = this.getParent();
        if (element2 != null && element2 != element) {
            return new StringBuffer().append(element2.getPath(element)).append("/processing-instruction()").toString();
        }
        return "processing-instruction()";
    }

    @Override
    public String getUniquePath(Element element) {
        Element element2 = this.getParent();
        if (element2 != null && element2 != element) {
            return new StringBuffer().append(element2.getUniquePath(element)).append("/processing-instruction()").toString();
        }
        return "processing-instruction()";
    }

    protected Map parseValues(String string2) {
        HashMap hashMap = new HashMap();
        StringTokenizer stringTokenizer = new StringTokenizer(string2, " ='\"", true);
        while (stringTokenizer.hasMoreTokens()) {
            String string3 = super.getName(stringTokenizer);
            if (!stringTokenizer.hasMoreTokens()) continue;
            hashMap.put((Object)string3, (Object)super.getValue(stringTokenizer));
        }
        return hashMap;
    }

    @Override
    public boolean removeValue(String string2) {
        return false;
    }

    @Override
    public void setName(String string2) {
        this.setTarget(string2);
    }

    @Override
    public void setValue(String string2, String string3) {
        throw new UnsupportedOperationException("This PI is read-only and cannot be modified");
    }

    @Override
    public void setValues(Map map) {
        throw new UnsupportedOperationException("This PI is read-only and cannot be modified");
    }

    public String toString() {
        return new StringBuffer().append(super.toString()).append(" [ProcessingInstruction: &").append(this.getName()).append(";]").toString();
    }

    protected String toString(Map map) {
        StringBuffer stringBuffer = new StringBuffer();
        for (Map.Entry entry : map.entrySet()) {
            String string2 = (String)entry.getKey();
            String string3 = (String)entry.getValue();
            stringBuffer.append(string2);
            stringBuffer.append("=\"");
            stringBuffer.append(string3);
            stringBuffer.append("\" ");
        }
        stringBuffer.setLength(-1 + stringBuffer.length());
        return stringBuffer.toString();
    }

    @Override
    public void write(Writer writer) throws IOException {
        writer.write("<?");
        writer.write(this.getName());
        writer.write(" ");
        writer.write(this.getText());
        writer.write("?>");
    }
}

