Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jackrabbit.oak.plugins.document.persistentCache;
import org.apache.jackrabbit.oak.plugins.document.LocalDiffCache;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
import org.apache.jackrabbit.oak.plugins.document.NodeDocument;
import org.apache.jackrabbit.oak.plugins.document.PathRev;
import org.apache.jackrabbit.oak.plugins.document.util.RevisionsKey;
import org.apache.jackrabbit.oak.plugins.document.util.StringValue;
public enum CacheType {
NODE {
@Override
public String keyToString(K key) {
return ((PathRev) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public K keyFromString(String key) {
return (K) PathRev.fromString(key);
}
@Override
public int compareKeys(K a, K b) {
return ((PathRev) a).compareTo((PathRev) b);
}
@Override
public String valueToString(V value) {
return ((DocumentNodeState) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
return (V) DocumentNodeState.fromString(store, value);
}
},
CHILDREN {
@Override
public String keyToString(K key) {
return ((PathRev) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public K keyFromString(String key) {
return (K) PathRev.fromString(key);
}
@Override
public int compareKeys(K a, K b) {
return ((PathRev) a).compareTo((PathRev) b);
}
@Override
public String valueToString(V value) {
return ((DocumentNodeState.Children) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
return (V) DocumentNodeState.Children.fromString(value);
}
},
DIFF {
@Override
public String keyToString(K key) {
return ((PathRev) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public K keyFromString(String key) {
return (K) PathRev.fromString(key);
}
@Override
public int compareKeys(K a, K b) {
return ((PathRev) a).compareTo((PathRev) b);
}
@Override
public String valueToString(V value) {
return ((StringValue) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
return (V) StringValue.fromString(value);
}
},
DOC_CHILDREN {
@Override
public String keyToString(K key) {
return ((StringValue) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public K keyFromString(String key) {
return (K) StringValue.fromString(key);
}
@Override
public int compareKeys(K a, K b) {
return ((StringValue) a).asString().compareTo(((StringValue) b).asString());
}
@Override
public String valueToString(V value) {
return ((NodeDocument.Children) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
return (V) NodeDocument.Children.fromString(value);
}
},
DOCUMENT {
@Override
public String keyToString(K key) {
return ((StringValue) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public K keyFromString(String key) {
return (K) StringValue.fromString(key);
}
@Override
public int compareKeys(K a, K b) {
return ((StringValue) a).asString().compareTo(((StringValue) b).asString());
}
@Override
public String valueToString(V value) {
return ((NodeDocument) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
return (V) NodeDocument.fromString(docStore, value);
}
},
LOCAL_DIFF {
@Override
public String keyToString(K key) {
return ((RevisionsKey) key).asString();
}
@SuppressWarnings("unchecked")
@Override
public K keyFromString(String key) {
return (K) RevisionsKey.fromString(key);
}
@Override
public int compareKeys(K a, K b) {
return ((RevisionsKey) a).compareTo((RevisionsKey) b);
}
@Override
public String valueToString(V value) {
return ((LocalDiffCache.Diff) value).asString();
}
@SuppressWarnings("unchecked")
@Override
public V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value) {
return (V) LocalDiffCache.Diff.fromString(value);
}
},
BLOB {
@Override
public String keyToString(K key) {
throw new UnsupportedOperationException();
}
@Override
public K keyFromString(String key) {
throw new UnsupportedOperationException();
}
@Override
public int compareKeys(K a, K b) {
throw new UnsupportedOperationException();
}
@Override
public String valueToString(V value) {
throw new UnsupportedOperationException();
}
@Override
public V valueFromString(DocumentNodeStore store,
DocumentStore docStore, String value) {
throw new UnsupportedOperationException();
}
};
public static final CacheType[] VALUES = CacheType.values();
public abstract String keyToString(K key);
public abstract K keyFromString(String key);
public abstract int compareKeys(K a, K b);
public abstract String valueToString(V value);
public abstract V valueFromString(
DocumentNodeStore store, DocumentStore docStore, String value);
}