Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 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.marmotta.platform.core.model.filter;
Accept only resources that are considered "local", i.e. either have the same URI prefix as the system, start with file:, start with urn:, or are blank nodes.

Author: Sebastian Schaffert

public class MarmottaLocalFilter implements ResourceFilter {
    public MarmottaLocalFilter() {
         = CDIContext.getInstance(ConfigurationService.class);
    private static MarmottaLocalFilter instance = null;
    public static MarmottaLocalFilter getInstance() {
        if( == null) {
             = new MarmottaLocalFilter();
        return ;

Return false in case the filter does not accept the resource passed as argument, true otherwise.

    public boolean accept(Resource resource) {
        if(resource instanceof BNode) {
            return true;
        URI uri = (URI)resource;
        if(uri.stringValue().startsWith("file:") || uri.stringValue().startsWith("urn:")) {
            return true;
        return uri.stringValue().startsWith(.getBaseUri());
New to GrepCode? Check out our FAQ X