@Override public Resource toResource() { return new FileResource(_file); } }
public FixedWidthDataContext(File file, FixedWidthConfiguration configuration) { super(true); _resource = new FileResource(file); _configuration = configuration; }
public FixedWidthDataContext(File file, FixedWidthConfiguration configuration) { super(true); _resource = new FileResource(file); _configuration = configuration; }
@Override protected ExcelDatastore createDatastore(final String name, final String filename) { return new ExcelDatastore(name, new FileResource(filename), filename, _columnNames); }
@Override public FileResource parsePath(String path) { final File file; if (_relativeParentDirectory != null && !isAbsolute(path)) { file = new File(_relativeParentDirectory, path); } else { file = new File(path); } return new FileResource(file); }
@Override public FileResource getResource() { final File file = getFile(); if (file == null) { return null; } return new FileResource(file); }
/** * @param file * @return the written count of rows */ public int write(final File file) { return write(new FileResource(file)); }
@Initialize public void initTempFile() throws Exception { if (_targetResource == null) { if (columnToBeSortedOn != null) { tempFile = File.createTempFile("csv_file_analyzer", ".csv"); _targetResource = new FileResource(tempFile); } else { _targetResource = file; } } }
public Resource getResourceToUse(final URI path) { if (path == null) { return null; } if (_hadoopConfiguration == null) { if ("hdfs".equals(path.getScheme())) { return new HdfsResource(path.toString()); } return new FileResource(path.toString()); } return new HadoopResource(path, _hadoopConfiguration, HadoopResource.DEFAULT_CLUSTERREFERENCE); }
@Override public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException { assert accepts(properties); final String path = properties.getUri().getPath(); return new FileResource(path); } }
@Override public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException { assert accepts(properties); final String path = properties.getUri().getPath(); return new FileResource(path); } }
@Override public Element createDatastoreElement(DocumentBuilder documentBuilder) { final DatastoreXmlExternalizer externalizer = new DatastoreXmlExternalizer(); final File file = new File(_filepath); final ExcelDatastore datastore = new ExcelDatastore(_name, new FileResource(file), _filepath); datastore.setDescription(_description); final Element ds = externalizer.toElement(datastore, _filepath); return ds; }
/** * Constructs a CSV DataContext based on an {@link InputStream} * * @param inputStream * @param configuration */ public CsvDataContext(InputStream inputStream, CsvConfiguration configuration) { File file = createFileFromInputStream(inputStream, configuration.getEncoding()); _configuration = configuration; _writable = false; _resource = new FileResource(file); }
@Override protected WriteDataResult getResultInternal(final int rowCount) { if (columnToBeSortedOn != null) { // Sorts the file using merge sort in the temporary file and then // write into the final file mergeSortFile(); } final FileResource resource = new FileResource(file); final Datastore datastore = new ExcelDatastore(file.getName(), resource, file.getAbsolutePath()); return new WriteDataResultImpl(rowCount, datastore, null, sheetName); }
/** * Constructs a CSV DataContext based on an {@link InputStream} * * @param inputStream * @param configuration */ public CsvDataContext(InputStream inputStream, CsvConfiguration configuration) { File file = createFileFromInputStream(inputStream, configuration.getEncoding()); _configuration = configuration; _writable = false; _resource = new FileResource(file); }
@Override public FileResource parsePath(final String path) { final FileResolver fileResolver = new FileResolver(_homeFolder); final File file = fileResolver.toFile(path); return new FileResource(file); }
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException { final ReadObjectBuilder.Adaptor adaptor = (getField, serializable) -> { final String filename = (String) getField.get("_filename", ""); final Field field = FixedWidthDatastore.class.getDeclaredField("_resourceRef"); field.setAccessible(true); final FileResource fileResource = new FileResource(filename); final SerializableRef<Resource> resourceRef = new SerializableRef<>(fileResource); field.set(serializable, resourceRef); }; ReadObjectBuilder.create(this, FixedWidthDatastore.class).readObject(stream, adaptor); }
@Override public void configureForTransformedData(final AnalysisJobBuilder ajb, final TransformerDescriptor<?> descriptor) { final String dsName = ajb.getDatastore().getName(); final File saveDatastoreDirectory = userPreferences.getSaveDatastoreDirectory(); final String displayName = descriptor.getDisplayName(); file = new FileResource(new File(saveDatastoreDirectory, dsName + "-" + displayName + ".csv")); }
@Override public void configureForFilterOutcome(final AnalysisJobBuilder ajb, final FilterDescriptor<?, ?> descriptor, final String categoryName) { final String dsName = ajb.getDatastore().getName(); final File saveDatastoreDirectory = userPreferences.getSaveDatastoreDirectory(); final String displayName = descriptor.getDisplayName(); file = new FileResource( new File(saveDatastoreDirectory, dsName + "-" + displayName + "-" + categoryName + ".csv")); }
protected Resource getResource(DataContextFactoryParameters params) { final org.springframework.core.io.Resource resource = params.getResource(); if (resource != null) { return new SpringResource(resource); } else if (params.getFilename() != null) { return new FileResource(params.getFilename()); } else if (params.getUrl() != null) { return new UrlResource(params.getUrl()); } return null; }