/**
 * 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.query.text.assembler;

import static org.apache.jena.query.text.assembler.TextVocab.pDirectory ;
import static org.apache.jena.query.text.assembler.TextVocab.pEntityMap ;

import java.io.File ;
import java.io.IOException ;

import org.apache.jena.atlas.io.IO ;
import org.apache.jena.query.text.EntityDefinition ;
import org.apache.jena.query.text.TextDatasetFactory ;
import org.apache.jena.query.text.TextIndex ;
import org.apache.jena.query.text.TextIndexException ;
import org.apache.jena.riot.system.IRILib ;
import org.apache.lucene.store.Directory ;
import org.apache.lucene.store.FSDirectory ;
import org.apache.lucene.store.RAMDirectory ;

import com.hp.hpl.jena.assembler.Assembler ;
import com.hp.hpl.jena.assembler.Mode ;
import com.hp.hpl.jena.assembler.assemblers.AssemblerBase ;
import com.hp.hpl.jena.rdf.model.RDFNode ;
import com.hp.hpl.jena.rdf.model.Resource ;
import com.hp.hpl.jena.sparql.util.graph.GraphUtils ;

public class TextIndexLuceneAssembler extends AssemblerBase
{
    /*
    <#index> a :TextIndexLucene ;
        #text:directory "mem" ;
        text:directory <file:DIR> ;
        text:entityMap <#endMap> ;
        .
    */

    @SuppressWarnings("resource")
    @Override
    public TextIndex open(Assembler a, Resource root, Mode mode)
    {
        try
        {
            if ( ! GraphUtils.exactlyOneProperty(root, pDirectory) )
                throw new TextIndexException("No 'text:directory' property on "+root) ;
            
            Directory directory ;
            RDFNode n = root.getProperty(pDirectory).getObject() ;
            if ( n.isLiteral() )
            {
                if ( ! "mem".equals(n.asLiteral().getLexicalForm()) )
                    throw new TextIndexException("No 'text:directory' property on "+root+ " is a literal and not \"mem\"") ;
                 directory = new RAMDirectory() ;
            }
            else
            { 
                Resource x = n.asResource() ;
                String path = IRILib.IRIToFilename(x.getURI()) ; 
                File dir = new File(path) ; 
                directory = FSDirectory.open(dir) ;
            }
        
            Resource r = GraphUtils.getResourceValue(root, pEntityMap) ;
            EntityDefinition docDef = (EntityDefinition)a.open(r) ; 
            
            return TextDatasetFactory.createLuceneIndex(directory, docDef) ;
        } catch (IOException e) { IO.exception(e) ; return null ;}
    }

}


@@ -845,16 +845,17 @@
 ssembler
+ 
 ;%0A%0Aimpor
@@ -1821,17 +1821,17 @@
 blerBase
-%0A
+ 
 %7B%0A    /*
@@ -1990,42 +1990,8 @@
 */%0A%0A
-    @SuppressWarnings(%22resource%22)%0A
     
@@ -2064,20 +2064,16 @@
 de mode)
-%0A   
  %7B%0A     
@@ -2078,24 +2078,16 @@
      try
-%0A       
  %7B%0A     
@@ -2099,17 +2099,16 @@
   if ( !
- 
 GraphUti
@@ -2232,17 +2232,19 @@
 on %22
-+
+ + 
 root) ;%0A
     
@@ -2239,28 +2239,16 @@
 root) ;%0A
-            
 %0A       
@@ -2373,28 +2373,16 @@
 eral() )
-%0A           
  %7B%0A     
@@ -2398,17 +2398,16 @@
   if ( !
- 
 %22mem%22.eq
@@ -2532,13 +2532,65 @@
 on %22
-+
+ + 
 root
+%0A                                                 
 + %22 
@@ -2618,25 +2618,24 @@
 %5C%22mem%5C%22%22) ;%0A
- 
             
@@ -2688,40 +2688,15 @@
    %7D
-%0A            else%0A           
+ else
  %7B
- 
 %0A   
@@ -2802,17 +2802,16 @@
 URI()) ;
- 
 %0A       
@@ -2846,17 +2846,16 @@
 (path) ;
- 
 %0A       
@@ -2913,24 +2913,16 @@
       %7D%0A
-        
 %0A       
@@ -3054,30 +3054,17 @@
 pen(r) ;
- %0A            
+%0A
 %0A       
@@ -3166,16 +3166,28 @@
 ion e) %7B
+%0A           
  IO.exce
@@ -3196,16 +3196,28 @@
 ion(e) ;
+%0A           
  return 
@@ -3226,16 +3226,25 @@
 ll ;
+%0A        
 %7D%0A    %7D%0A
 %0A%7D%0A%0A
@@ -3243,8 +3243,6 @@
   %7D%0A
-%0A
 %7D%0A
-%0A

Remove @SuppressWarnings, because in Eclispe Kepler it generates a warning.