Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2012 Martin Skurla
  *
  * Licensed 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.crazyjavahacking.astvisualizer.impl.javac.util;
JavaFileObject utility class.

Author(s):
Martin
public final class JavaFileObjectUtils {
    //-----------------------------------------------------------------------------------------------------------------
    // Constructors.
    //-----------------------------------------------------------------------------------------------------------------
    private JavaFileObjectUtils() {}
    //-----------------------------------------------------------------------------------------------------------------
    // Public Methods.
    //-----------------------------------------------------------------------------------------------------------------
    
Creates JavaFileObject from reader.

Parameters:
javaSourceReader java source reader
simpleClassName simple class name
Returns:
JavaFileObject
See also:
javax.tools.JavaFileObject
    public static JavaFileObject fromReader(Reader javaSourceReaderString simpleClassName) {
        return new JavaFileObjectFromReader(javaSourceReadersimpleClassName);
    }
    //-----------------------------------------------------------------------------------------------------------------
    // Inner classes.
    //-----------------------------------------------------------------------------------------------------------------
Represents JavaFileObject constructed from Reader.
    private static final class JavaFileObjectFromReader extends SimpleJavaFileObject {
        private final String fileObjectContent;
        private JavaFileObjectFromReader(Reader javaSourceReaderString simpleClassName) {
            super(URI.create(String.format("string:///%s.java"simpleClassName)),
                  .);
            try {
                this. = CharStreams.toString(javaSourceReader);
            }
            catch (IOException e) {
                throw new IllegalStateException("IOException during reading JavaFileObject content...");
            }
        }
        @Override
        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
            return ;
        }
    }
New to GrepCode? Check out our FAQ X