org.netbeans.modules.turbo.TurboProvider Maven / Gradle / Ivy
/*
* 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.netbeans.modules.turbo;
import java.util.List;
/**
* SPI, extension point allowing third parties to redefine
* attribute reading and writing. Must be registered
* in default {@link org.openide.util.Lookup}.
*
* It must generally deternime that they
* support given entity key and attribute pair
* and if so then perform action.
*
* Two providers can theoreticaly clash and support
* the same attribute for the same entity key. The
* key point is that attribute meaning must be precisely
* defined guaranteeing that two independent providers
* respond with exactly same value hence making irrelevant
* which one is actually choosen.
*
* Providers should not cache results.
*
* @author Petr Kuzel
*/
public interface TurboProvider {
/**
* Reports if an attribute is supported by the implementation.
*/
boolean recognizesAttribute(String name);
/**
* Reports if the entity identified by key is supported by the implementation.
*/
boolean recognizesEntity(Object key);
/**
* Reads given attribute for given fileobject. No method
* parameter may be referenced after method execution finishes.
*
* @param key identifies source entity, never null
* @param name identifies requested attribute, never null
* @param memoryCache can store speculative results
* @return attribute value or null
if it does not exist.
*/
Object readEntry(Object key, String name, MemoryCache memoryCache);
/**
* Writes given attribute. No method
* parameter may be referenced after method execution finishes.
*
* @param key identifies target entity, never null
* @param name identifies attribute, never null
* @param value actual attribute value that should be stored or null
for removing it
* @return false
on write failure if provider denies the value. On I/O error it
* returns true
.
*/
boolean writeEntry(Object key, String name, Object value);
/**
* Provides direct access to memory layer (without
* delegating to providers layer, here source).
*/
public static final class MemoryCache {
private final boolean enabled;
private final List