org.apache.jena.iri.impl.IRIFactoryImpl 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.apache.jena.iri.impl;
import java.io.UnsupportedEncodingException;
import java.util.AbstractSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.apache.jena.iri.IRI ;
import org.apache.jena.iri.IRIComponents ;
import org.apache.jena.iri.ViolationCodes ;
public class IRIFactoryImpl
extends AbsIRIFactoryImpl
implements ViolationCodes, Force, IRIComponents {
public static final int UNKNOWN_SYNTAX = -4;
// boolean throwUncheckedExceptions = false;
/*
static final long conformanceMasks[] = {
// RFC3986
(1l< specs = new HashSet<>();
public IRIFactoryImpl() {
}
public IRIFactoryImpl(IRIFactoryImpl template) {
if (backwardCompatibleRelativeRefs.size()==Integer.MAX_VALUE)
backwardCompatibleRelativeRefs = template.backwardCompatibleRelativeRefs;
else
backwardCompatibleRelativeRefs = new HashSet<>(backwardCompatibleRelativeRefs);
encoding = template.encoding;
errors = template.errors;
prohibited = template.prohibited;
required = template.required;
warnings = template.warnings;
System.arraycopy(template.asErrors,0,asErrors,0,asErrors.length);
System.arraycopy(template.asWarnings,0,asWarnings,0,asWarnings.length);
for ( Entry entry : template.schemes.entrySet() )
{
SchemeSpecificPart p = entry.getValue();
if ( p.withScheme() )
{
schemes.put( entry.getKey(), new WithScheme( (WithScheme) p ) );
}
else if ( p.port() != IRI.NO_PORT )
{
schemes.put( entry.getKey(), new NoScheme( p.port() ) );
}
}
}
/*
protected long recsToMask(int recs) {
long mask = 0;
for (int i=0; recs != 0 && i backwardCompatibleRelativeRefs = new HashSet<>();
protected void initializing() {
if (!initializing)
throw new IllegalStateException("Cannot reinitialize IRIFactory after first use.");
}
@Override
public IRI create(String s) {
initializing = false;
return super.create(s);
}
public void setSameSchemeRelativeReferences(String scheme) {
if (scheme.equals("*"))
backwardCompatibleRelativeRefs = new AbstractSet(){
@Override
public int size() {
return Integer.MAX_VALUE;
}
@Override
public Iterator iterator() {
throw new UnsupportedOperationException();
}
@Override
public boolean add(String o) {
return false;
}
@Override
public boolean contains(Object o) {
return true;
}
};
else
backwardCompatibleRelativeRefs.add(scheme.toLowerCase());
}
protected void useSpec(String name, boolean asErr) {
initializing();
Specification spec = Specification.get(name);
specs.add(spec);
for (int i=0; i schemes = new HashMap<>();
public void useSchemeSpecificRules(String scheme, boolean asErr)
{
if (scheme.equals("*"))
{
for ( String s : Specification.schemes.keySet() )
{
scheme = s;
if ( !schemes.containsKey( scheme ) )
{
useSchemeSpecificRules( scheme, asErr );
}
}
return ;
}
scheme = scheme.toLowerCase() ;
SchemeSpecification spec = (SchemeSpecification) Specification.schemes.get(scheme) ;
if (spec == null)
{
schemes.put(scheme, noScheme) ;
} else
{
schemes.put(scheme, new WithScheme(spec, asErr)) ;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy