TODO: used shared static method in JavacFileManager
480265
@Override
    public StandardJavaFileManager getStandardFileManager(
            DiagnosticListener<? super JavaFileObject> diagnosticListener,
            Locale locale,
            Charset charset) {
        Context context = new Context();
        context.put(Locale.class, locale);
        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, diagnosticListener);
        PrintWriter pw = (charset == null)
                ? new PrintWriter(System.err, true)
                : new PrintWriter(new OutputStreamWriter(System.err, charset), true);
        context.put(Log.outKey, pw);
        return new JavacFileManager(context, true, charset);
    }
727917
public static void main(String[] args) throws Exception {
    StringUtils.printErrInvocationString("CMMClassifier", args);

    Properties props = StringUtils.argsToProperties(args);
    CMMClassifier cmm = new CMMClassifier<CoreLabel>(props);
    String testFile = cmm.flags.testFile;
    String textFile = cmm.flags.textFile;
    String loadPath = cmm.flags.loadClassifier;
    String serializeTo = cmm.flags.serializeTo;

    // cmm.crossValidateTrainAndTest(trainFile);
    if (loadPath != null) {
      cmm.loadClassifierNoExceptions(loadPath, props);
    } else if (cmm.flags.loadJarClassifier != null) {
      cmm.loadJarClassifier(cmm.flags.loadJarClassifier, props);
    } else if (cmm.flags.trainFile != null) {
      if (cmm.flags.biasedTrainFile != null) {
        cmm.trainSemiSup();
      } else {
        cmm.train();
      }
    } else {
      cmm.loadDefaultClassifier();
    }

    if (serializeTo != null) {
      cmm.serializeClassifier(serializeTo);
    }

    if (testFile != null) {
      cmm.classifyAndWriteAnswers(testFile, cmm.makeReaderAndWriter());
    } else if (cmm.flags.testFiles != null) {
      cmm.classifyAndWriteAnswers(cmm.flags.baseTestDir, cmm.flags.testFiles,
                                  cmm.makeReaderAndWriter());
    }

    if (textFile != null) {
      DocumentReaderAndWriter readerAndWriter =
        new PlainTextDocumentReaderAndWriter();
      cmm.classifyAndWriteAnswers(textFile, readerAndWriter);
    }
  }
1194749
@Override
  public final HndlEntityFileReportReq<RS>
    lazyGetHndlEntityFileReportReq() throws Exception {
    String beanName = this.factoryAppBeans.getHndlEntityFileReportReqName();
    @SuppressWarnings("unchecked")
    HndlEntityFileReportReq<RS> hndlEfrr = (HndlEntityFileReportReq<RS>)
      this.factoryAppBeans.getBeansMap().get(beanName);
    if (hndlEfrr == null) {
      hndlEfrr = new HndlEntityFileReportReq<RS>();
      hndlEfrr
        .setSrvDatabase(this.factoryAppBeans.lazyGetSrvDatabase());
      hndlEfrr.setReadTi(this.factoryAppBeans.getReadTi());
      hndlEfrr.setFillEntityFromReq(
        this.factoryAppBeans.lazyGetFillEntityFromReq());
      hndlEfrr
        .setEntitiesFactoriesFatory(lazyGetFctBcFctSimpleEntities());
      hndlEfrr
        .setFctEntitiesFileReporters(this.fctEntitiesFileReporters);
      @SuppressWarnings("unchecked")
      HashMap<String, Class<?>> mcl = (HashMap<String, Class<?>>)
        this.factoryAppBeans.getEntitiesMap().clone();
      hndlEfrr.setEntitiesMap(mcl);
      this.factoryAppBeans.getBeansMap().put(beanName, hndlEfrr);
      this.factoryAppBeans.lazyGetLogger().info(null, AFactoryAppBeans.class,
        beanName + " has been created.");
    }
    return hndlEfrr;
  }
333895
static File preferencesFile() {
        final File userDir = new File(System.getProperty("user.home"));
        final File prefDir = (userDir.canWrite())
            ? new File(userDir, ".acolyte") : null;

        if (prefDir != null && !prefDir.exists()) {
            prefDir.mkdir();
        } // end of if

        return (prefDir != null && prefDir.canRead() && prefDir.canWrite())
            ? new File(prefDir, "studio.properties") : null;

    }
1289833
public void parseConllFileNoParallel(String inputFile, String outputFile, boolean rootFirst, int beamWidth, boolean labeled, boolean lowerCased, int numOfThreads, boolean partial, String scorePath) throws IOException, ExecutionException, InterruptedException
    {
        CoNLLReader reader = new CoNLLReader(inputFile);
        boolean addScore = false;
        if (scorePath.trim().length() > 0)
            addScore = true;
        ArrayList<Float> scoreList = new ArrayList<Float>();

        long start = System.currentTimeMillis();
        int allArcs = 0;
        int size = 0;
        BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile + ".tmp"));
        int dataCount = 0;

        while (true)
        {
            ArrayList<Instance> data = reader.readData(15000, true, labeled, rootFirst, lowerCased, maps);
            size += data.size();
            if (data.size() == 0)
                break;

            for (Instance instance : data)
            {
                dataCount++;
                if (dataCount % 100 == 0)
                    System.err.print(dataCount + " ... ");
                Configuration bestParse;
                if (partial)
                    bestParse = parsePartial(instance, instance.getSentence(), rootFirst, beamWidth, numOfThreads);
                else bestParse = parse(instance.getSentence(), rootFirst, beamWidth, numOfThreads);

                int[] words = instance.getSentence().getWords();
                allArcs += words.length - 1;
                if (addScore)
                    scoreList.add(bestParse.score / bestParse.sentence.size());

                writeParsedSentence(writer, rootFirst, bestParse, words);
            }
        }

//        System.err.print("\n");
        long end = System.currentTimeMillis();
        float each = (1.0f * (end - start)) / size;
        float eacharc = (1.0f * (end - start)) / allArcs;

        writer.flush();
        writer.close();

//        DecimalFormat format = new DecimalFormat("##.00");
//
//        System.err.print(format.format(eacharc) + " ms for each arc!\n");
//        System.err.print(format.format(each) + " ms for each sentence!\n\n");

        BufferedReader gReader = new BufferedReader(new FileReader(inputFile));
        BufferedReader pReader = new BufferedReader(new FileReader(outputFile + ".tmp"));
        BufferedWriter pwriter = new BufferedWriter(new FileWriter(outputFile));

        String line;

        while ((line = pReader.readLine()) != null)
        {
            String gLine = gReader.readLine();
            if (line.trim().length() > 0)
            {
                while (gLine.trim().length() == 0)
                    gLine = gReader.readLine();
                String[] ps = line.split("\t");
                String[] gs = gLine.split("\t");
                gs[6] = ps[0];
                gs[7] = ps[1];
                StringBuilder output = new StringBuilder();
                for (int i = 0; i < gs.length; i++)
                {
                    output.append(gs[i]).append("\t");
                }
                pwriter.write(output.toString().trim() + "\n");
            }
            else
            {
                pwriter.write("\n");
            }
        }
        pwriter.flush();
        pwriter.close();

        if (addScore)
        {
            BufferedWriter scoreWriter = new BufferedWriter(new FileWriter(scorePath));

            for (int i = 0; i < scoreList.size(); i++)
                scoreWriter.write(scoreList.get(i) + "\n");
            scoreWriter.flush();
            scoreWriter.close();
        }
        IOUtil.deleteFile(outputFile + ".tmp");
    }
104752
public void compile() throws JasperException, FileNotFoundException {
        createCompiler();
        if (jspCompiler.isOutDated()) {
            if (isRemoved()) {
                throw new FileNotFoundException(jspUri);
            }
            try {
                jspCompiler.removeGeneratedFiles();
                jspLoader = null;
                jspCompiler.compile();
                jsw.setReload(true);
                jsw.setCompilationException(null);
            } catch (JasperException ex) {
                // Cache compilation exception
                jsw.setCompilationException(ex);
                if (options.getDevelopment() && options.getRecompileOnFail()) {
                    // Force a recompilation attempt on next access
                    jsw.setLastModificationTest(-1);
                }
                throw ex;
            } catch (FileNotFoundException fnfe) {
                // Re-throw to let caller handle this - will result in a 404
                throw fnfe;
            } catch (Exception ex) {
                JasperException je = new JasperException(
                        Localizer.getMessage("jsp.error.unable.compile"),
                        ex);
                // Cache compilation exception
                jsw.setCompilationException(je);
                throw je;
            }
        }
    }
1142092
private void invokeFactoryMethod(MethodDefinition read, Map<Short, LocalVariableDefinition> structData, LocalVariableDefinition instance)
    {
        if (metadata.getBuilderMethod().isPresent()) {
            ThriftMethodInjection builderMethod = metadata.getBuilderMethod().get();
            read.loadVariable(instance);

            // push parameters on stack
            for (ThriftParameterInjection parameter : builderMethod.getParameters()) {
                read.loadVariable(structData.get(parameter.getId()));
            }

            // invoke the method
            read.invokeVirtual(builderMethod.getMethod())
                    .storeVariable(instance);
        }
    }
858636
public void init() throws IOException {
    if (!Files.exists(path)) {
      throw new FileNotFoundException(
          "Could not find a file under path: " + path.toAbsolutePath().toString());
    }
    if (Files.size(path) == 0) {
      throw new IllegalStateException("File size can't be zero for chunked files");
    }
    chunks = chunkFile();
    chunksInUse = new ConcurrentSkipListMap<>();
    chunksPreRead = new ConcurrentSkipListMap<>();
    chunksScheduled = new ConcurrentSkipListMap<>();
    nextChunkNum = new AtomicInteger(-1);
    if (raf != null) {
      raf.close();
    }
    execIo = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
    execFinalize = Executors.newSingleThreadExecutor();
  }
624786
public JavacFiler getJavacFiler(Object filer) {
		if (filer instanceof JavacFiler) return (JavacFiler) filer;
		
		// try to find a "delegate" field in the object, and use this to check for a JavacFiler
		for (Class<?> filerClass = filer.getClass(); filerClass != null; filerClass = filerClass.getSuperclass()) {
			try {
				return getJavacFiler(tryGetDelegateField(filerClass, filer));
			} catch (final Exception e) {
				// delegate field was not found, try on superclass
			}
		}
		
		processingEnv.getMessager().printMessage(Kind.WARNING,
			"Can't get a JavacFiler from " + filer.getClass().getName() + ". Lombok won't work.");
		return null;
	}
1306968
@Override
    public T fromFile(final File file) throws IllegalArgumentException, DescriptorImportException {
        // Precondition checks
        if (file == null) {
            throw new IllegalArgumentException("File not specified");
        }

        // Delegate
        try {
            return this.fromStream(new FileInputStream(file));
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("Specified file does not exist or is a directory: "
                + file.getAbsolutePath());
        }
    }
171191
private RemoteIterator<LocatedFileStatus> arrayListing(final String src)
  throws IOException {
    return new RemoteIterator<LocatedFileStatus>() {
      private FileStatus[] stats;
      private int i = 0;

      { //initializer
        stats = listPaths(src);
        if (stats == null) {
          throw new FileNotFoundException("File " + src + " does not exist.");
        }
      }

      @Override
      public boolean hasNext() throws IOException {
        return i<stats.length;
      }

      @Override
      public LocatedFileStatus next() throws IOException {
        if (!hasNext()) {
          throw new NoSuchElementException("No more entry in " + src);
        }
        FileStatus result = stats[i++];
        BlockLocation[] locs = result.isDir() ? null :
            getBlockLocations(
                result.getPath().toUri().getPath(), 0, result.getLen());
        return new LocatedFileStatus(result, locs);
      }
    };
  }
288241
@Override
    public void prepareFileTypeAnalyzer(Engine engine) throws InitializationException {
        LOGGER.debug("Initializing Central analyzer");
        LOGGER.debug("Central analyzer enabled: {}", isEnabled());
        if (isEnabled()) {
            try {
                searcher = new CentralSearch(getSettings());
            } catch (MalformedURLException ex) {
                setEnabled(false);
                throw new InitializationException("The configured URL to Maven Central is malformed", ex);
            }
        }
    }
72158
private void doMethod(CtBehavior method) throws NotFoundException, CannotCompileException {

        String signature = JavassistHelper.getSignature(method);
        String returnValue = JavassistHelper.returnValue(method);

        if (addEntryExit) {
            String messagePattern = "if ({}.{}()) {}.{}(\">> {}\");";
            Object[] arg1 = new Object[] { loggerName, levelEnabled, loggerName, level, signature };
            String before = MessageFormatter.arrayFormat(messagePattern, arg1).getMessage();
            // System.out.println(before);
            method.insertBefore(before);

            String messagePattern2 = "if ({}.{}()) {}.{}(\"<< {}{}\");";
            Object[] arg2 = new Object[] { loggerName, levelEnabled, loggerName, level, signature, returnValue };
            String after = MessageFormatter.arrayFormat(messagePattern2, arg2).getMessage();
            // System.out.println(after);
            method.insertAfter(after);
        }
    }
365051
static File openFileDialog(Frame frame, FileFilter fileFilter, File initialDir) {
    return openFileDialog(frame, fileFilter, initialDir, JFileChooser.FILES_ONLY);
  }
1216458
private static FileMonitor createFileMonitor(String [] args)
   throws Exception
   {
        String usage= " Usage: [-pollingInterval <timems>]? [-observer <class>]* [-monitor <dir>:<filter>:<ignoreCurrentContentBoolean>]*";

      if(args == null || args.length < 2 )
         throw new IllegalArgumentException(usage);
      
      FileMonitor fileMonitor =new FileMonitor();
      
      String [] arrayString = null;
      SubjectObserver<FileEvent> observer = null;
      for(int i=0; i < args.length;i++)
      {
         if("-monitor".equals(args[i]))
         {
            if(i+1 >= args.length)
            {
               throw new IllegalArgumentException("directory:filter specified -monitor argument "+usage);
            }
            
            arrayString = args[i+1].split(":");
            if(arrayString.length != 3)
               throw new IllegalArgumentException(args[i+1]+usage );
            
            fileMonitor.monitor(arrayString[0],arrayString[1],Boolean.valueOf(arrayString[2]).booleanValue());

            i = i+1;
         }
         else if("-pollingInterval".equals(args[i]))
         {
            if(i+1 >= args.length)
            {
               throw new IllegalArgumentException("no time specified -pollingInterval argument "+usage);
            }
            
            fileMonitor.setPollingInterval(Long.parseLong(args[i+1]));
            i = i+1;
         }
         else if("-observer".equals(args[i]))
         {
            if(i+1 >= args.length)
            {
               throw new IllegalArgumentException("no observer specific in -observer argument "+usage);
            }
               
            //fileMonitor.addObserver((Observer)Class.forName(args[i+1]).newInstance());
            observer = ClassPath.newInstance(args[i+1]);
            fileMonitor.add(observer);
            i = i+1;
         }
       }//end for
      return fileMonitor;
   }
403929
public static void preRegisterFileManager(Context context) {
    context.put(
        JavaFileManager.class,
        new Context.Factory<JavaFileManager>() {
          @Override
          public JavaFileManager make(Context c) {
            return new MaskedFileManager(c);
          }
        });
  }
1296304
public static void preRegister(Context context) {
        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
            public JavaFileManager make(Context c) {
                return new JavacFileManager(c, true, null);
            }
        });
    }