影视仓 v5.0.24版本的 MD5 值为:620341689ccdc375a3b86527e140060e

以下内容为反编译后的 FilePersistenceStrategy.java 源代码,内容仅作参考


package com.thoughtworks.xstream.persistence;

import com.androidx.y0;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.SingleValueConverter;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.File;
public class FilePersistenceStrategy extends AbstractFilePersistenceStrategy {
    private final String illegalChars;

    public FilePersistenceStrategy(File file) {
        this(file, new XStream(new DomDriver()));
    }

    public String escape(String str) {
        char[] charArray;
        StringBuffer stringBuffer = new StringBuffer();
        for (char c : str.toCharArray()) {
            if (c >= ' ' && this.illegalChars.indexOf(c) < 0) {
                stringBuffer.append(c);
            } else {
                StringBuffer stringBuffer2 = new StringBuffer("%");
                stringBuffer2.append(Integer.toHexString(c).toUpperCase());
                stringBuffer.append(stringBuffer2.toString());
            }
        }
        return stringBuffer.toString();
    }

    @Override
    public Object extractKey(String str) {
        String unescape = unescape(str.substring(0, str.length() - 4));
        if ("null@null".equals(unescape)) {
            return null;
        }
        int indexOf = unescape.indexOf(64);
        if (indexOf >= 0) {
            Class realClass = getMapper().realClass(unescape.substring(0, indexOf));
            Converter lookupConverterForType = getConverterLookup().lookupConverterForType(realClass);
            if (lookupConverterForType instanceof SingleValueConverter) {
                return ((SingleValueConverter) lookupConverterForType).fromString(unescape.substring(indexOf + 1));
            }
            ConversionException conversionException = new ConversionException("No SingleValueConverter available for key type");
            conversionException.add("key-type", realClass.getName());
            throw conversionException;
        }
        ConversionException conversionException2 = new ConversionException("No valid key");
        conversionException2.add(y0.KEY, unescape);
        throw conversionException2;
    }

    @Override
    public String getName(Object obj) {
        if (obj == null) {
            return "null@null.xml";
        }
        Class<?> cls = obj.getClass();
        Converter lookupConverterForType = getConverterLookup().lookupConverterForType(cls);
        if (lookupConverterForType instanceof SingleValueConverter) {
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append(getMapper().serializedClass(cls));
            stringBuffer.append('@');
            stringBuffer.append(escape(((SingleValueConverter) lookupConverterForType).toString(obj)));
            stringBuffer.append(".xml");
            return stringBuffer.toString();
        }
        ConversionException conversionException = new ConversionException("No SingleValueConverter available for key type");
        conversionException.add("key-type", cls.getName());
        throw conversionException;
    }

    @Override
    public boolean isValid(File file, String str) {
        return super.isValid(file, str) && str.indexOf(64) > 0;
    }

    public String unescape(String str) {
        StringBuffer stringBuffer = new StringBuffer();
        while (true) {
            int indexOf = str.indexOf(37);
            if (indexOf >= 0) {
                stringBuffer.append(str.substring(0, indexOf));
                int i = indexOf + 1;
                int i2 = indexOf + 3;
                stringBuffer.append((char) Integer.parseInt(str.substring(i, i2), 16));
                str = str.substring(i2);
            } else {
                stringBuffer.append(str);
                return stringBuffer.toString();
            }
        }
    }

    public FilePersistenceStrategy(File file, XStream xStream) {
        this(file, xStream, "utf-8", "<>?:/\\\"|*%");
    }

    public FilePersistenceStrategy(File file, XStream xStream, String str, String str2) {
        super(file, xStream, str);
        this.illegalChars = str2;
    }
}