All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.github.evenjn.xml.Xml Maven / Gradle / Ivy

The newest version!
/**
 *
 * Copyright 2017 Marco Trevisan
 *
 * 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.github.evenjn.xml;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.github.evenjn.lang.Rook;
import org.github.evenjn.yarn.Cursable;
import org.github.evenjn.yarn.Cursor;

public class Xml {

	public static XmlDecoderBlueprint decoder( ) {
		return new XmlDecoderBlueprint( );
	}

	static public Cursable fileRead( String file ) {
		Path path = Paths.get( file );
		return new Cursable( ) {

			@Override
			public Cursor pull( Rook rook ) {
				try {
					InputStream is = rook.hook( Files.newInputStream( path ) );
					return new XmlDecoderBlueprint( ).build().get( rook, is );
				}
				catch ( IOException e ) {
					throw new RuntimeException( e );
				}
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy