当前位置: 首页>>代码示例>>Java>>正文


Java ReaderException类代码示例

本文整理汇总了Java中org.vast.util.ReaderException的典型用法代码示例。如果您正苦于以下问题:Java ReaderException类的具体用法?Java ReaderException怎么用?Java ReaderException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReaderException类属于org.vast.util包,在下文中一共展示了ReaderException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.vast.util.ReaderException; //导入依赖的package包/类
@Override
public int process(DataBlock data, int index) throws IOException
{
    String token = readToken();
    
    try
    {
        int val = Integer.parseInt(token);
        data.setIntValue(index, val);
        return ++index;
    }
    catch (NumberFormatException e)
    {
        throw new ReaderException(INVALID_INTEGER_MSG + token);
    }            
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:17,代码来源:TextDataParser.java

示例2: processBlock

import org.vast.util.ReaderException; //导入依赖的package包/类
@Override
protected boolean processBlock(DataComponent component) throws IOException
{
	if (component instanceof DataChoiceImpl)
	{
		String token = null;
		
		// read implicit choice token
		try
		{
			token = readToken();
			((DataChoiceImpl)component).setSelectedItem(token);
		}
		catch (Exception e)
		{
			throw new ReaderException(CHOICE_ERROR + token, e);
		}
	}
	
	return true;
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:22,代码来源:AsciiDataParser.java

示例3: parseNextBlock

import org.vast.util.ReaderException; //导入依赖的package包/类
/**
 * Parse next atom from stream
 */
@Override
   public DataBlock parseNextBlock() throws IOException
{
	try
       {
           do
           {
               if (!moreData())
                   return null;
               
               this.processNextElement();
           }
           while (!componentStack.isEmpty());
           
           return dataComponents.getData();
       }
       catch (Exception e)
       {
           throw new ReaderException(e);
       }
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:25,代码来源:AbstractDataParser.java

示例4: parse

import org.vast.util.ReaderException; //导入依赖的package包/类
/**
 * Start parsing data coming from the given stream
 */
@Override
   public void parse(InputStream inputStream) throws IOException
{
       stopParsing = false;
       
       try
	{
       	setInput(inputStream);
		
		do
		{
			// stop if end of stream
			if (!moreData())
				break;
			
			processNextElement();
		}
		while(!stopParsing && !endOfArray);
	}
       catch (Exception e)
       {
           throw new ReaderException(STREAM_ERROR, e);
       }
	finally
	{
		inputStream.close();
		// dataComponents.clearData();
	}
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:33,代码来源:AsciiDataParser.java

示例5: read

import org.vast.util.ReaderException; //导入依赖的package包/类
public void read(DOMHelper dom, Element parentElt) throws IOException
{
	this.dom = dom;
	
	/*namespace = ((XmlEncoding)dataEncoding).namespace;
	prefix = "data";
	
	if (namespace != null)
		dom.addUserPrefix(prefix, namespace);*/
	
	currentParentElt = parentElt;
	numRecord = dom.getChildElements(parentElt).getLength(); 
		
	try
       {
           do
           {
           	// stop if end of stream
           	if (!moreData())
           		break;
           	
           	processNextElement();
           }
           while(!stopParsing && !endOfArray);
       }
       catch (Exception e)
       {
           throw new ReaderException(STREAM_ERROR, e);
       }
	
	//dataComponents.clearData();
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:33,代码来源:XmlDataParserDOM.java

示例6: processAtom

import org.vast.util.ReaderException; //导入依赖的package包/类
@Override
protected void processAtom(ScalarComponent component) throws IOException
{
	setCurrentParent();
	String localName = component.getName();
	String val;
	
	// special case of array size -> read from elementCount attribute
	if (localName.equals(AbstractArrayImpl.ELT_COUNT_NAME))
	{
		val = dom.getAttributeValue(currentParentElt, localName);
	}
	
	// else read from element content
	else
	{
		Element currentElt = getCurrentElement(component);
		val = dom.getElementValue(currentElt);
	}
	
	//System.out.println(scalarInfo.getName());
	try
       {
           tokenParser.parseToken(component, val, (char)0);
       }
       catch (Exception e)
       {
           throw new ReaderException("Invalid value '" + val + "' for scalar component '" + localName + "'", e);
       }
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:31,代码来源:XmlDataParserDOM.java

示例7: setInput

import org.vast.util.ReaderException; //导入依赖的package包/类
@Override
   public void setInput(InputStream inputStream) throws IOException
{
	InputStream dataIn = null;
	
	// use Base64 converter
	switch (((BinaryEncoding)dataEncoding).getByteEncoding())
	{
		case BASE_64:
			dataIn = new BufferedInputStream(new Base64Decoder(inputStream), 1024);
			break;
			
		case RAW:
			dataIn = inputStream;
			break;
			
		default:
			throw new ReaderException("Unsupported byte encoding");
	}
	
	// create data input stream
	if (((BinaryEncoding)dataEncoding).getByteOrder() == ByteOrder.LITTLE_ENDIAN)
           input = new DataInputStreamLI(dataIn);
	else
	    input = new DataInputStreamBI(dataIn);
	
	dataInput = (DataInputExt)input;
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:29,代码来源:BinaryDataParser.java

示例8: parse

import org.vast.util.ReaderException; //导入依赖的package包/类
public DataBlock parse() throws IOException
{
    try
       {
           do processNextElement();
           while(!isEndOfDataBlock());
       }
       catch (Exception e)
       {
           throw new ReaderException(STREAM_ERROR, e);
       }
    
    return dataComponents.getData();
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:15,代码来源:BinaryDataParser.java

示例9: processBlock

import org.vast.util.ReaderException; //导入依赖的package包/类
@Override
protected boolean processBlock(DataComponent blockComponent) throws IOException
{
	if (blockComponent instanceof DataChoiceImpl)
	{
		int choiceIndex = -1;
		
		// read implicit choice index
		try
		{
			choiceIndex = dataInput.readByte();
			((DataChoiceImpl)blockComponent).setSelectedItem(choiceIndex);
		}
		catch (Exception e)
		{
			throw new ReaderException(CHOICE_ERROR + choiceIndex, e);
		}
	}
	else
	{		
		// get block encoding details
		BinaryMember binaryInfo = ((AbstractDataComponentImpl)blockComponent).getEncodingInfo();
		
		// parse whole block at once if compression found
		if (binaryInfo != null)
		{
			parseBinaryBlock(blockComponent, (BinaryBlockImpl)binaryInfo);
			return false;
		}
	}
	
	return true;
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:34,代码来源:BinaryDataParser.java

示例10: parseBinaryBlock

import org.vast.util.ReaderException; //导入依赖的package包/类
/**
 * Parse binary block using DataInfo and DataEncoding structures
 * Decoded value is assigned to each DataValue
 * @param blockComponent
 * @param binaryInfo
 * @throws CDMException
 */
private void parseBinaryBlock(DataComponent blockComponent, BinaryBlockImpl binaryInfo) throws IOException
{
	try
       {
           // TODO: PADDING IS TAKEN CARE OF HERE... 
           
           DataBlock dataBlock = blockComponent.getData();
           
           if (dataBlock instanceof DataBlockCompressed)
           {
               // read block size
               int blockSize = dataInput.readInt();
               byte[] bytes = new byte[blockSize];
               dataInput.readFully(bytes);
               dataBlock.setUnderlyingObject(bytes);
           }
           
           // otherwise need to uncompress on-the-fly
           else
           {
               // if decoder is specified, uncompress data now
               CompressedStreamParser reader = binaryInfo.getBlockReader();
               if (reader != null)
               {
                   reader.decode(dataInput, blockComponent);
               }
           }
       }
       catch (IOException | CDMException e)
       {
           throw new ReaderException("Cannot parse binary block", e);
       }
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:41,代码来源:BinaryDataParser.java

示例11: handleRequest

import org.vast.util.ReaderException; //导入依赖的package包/类
@Override
protected void handleRequest(InsertResultRequest request) throws Exception
{
    DataStreamParser parser = null;
    
    checkTransactionalSupport(request);
    String templateID = request.getTemplateId();
    
    // retrieve consumer based on template id
    ISOSDataConsumer consumer = (ISOSDataConsumer)getDataConsumerByTemplateID(templateID);
    Template template = consumer.getTemplate(templateID);
    DataComponent dataStructure = template.component;
    DataEncoding encoding = template.encoding;
    
    try
    {
        InputStream resultStream;
        
        // select data source (either inline XML or in POST body for KVP)
        DataSource dataSrc = request.getResultDataSource();
        if (dataSrc instanceof DataSourceDOM) // inline XML
        {
            encoding = SWEHelper.ensureXmlCompatible(encoding);
            resultStream = dataSrc.getDataStream();
        }
        else // POST body
        {
            resultStream = new BufferedInputStream(request.getHttpRequest().getInputStream());
        }
        
        // create parser
        parser = SWEHelper.createDataParser(encoding);
        parser.setDataComponents(dataStructure);
        parser.setInput(resultStream);
                    
        // parse each record and send it to consumer
        DataBlock nextBlock = null;
        while ((nextBlock = parser.parseNextBlock()) != null)
            consumer.newResultRecord(templateID, nextBlock);
        
        // build and send response
        InsertResultResponse resp = new InsertResultResponse();
        sendResponse(request, resp);
    }
    catch (ReaderException e)
    {
        throw new SOSException("Error in SWE encoded data", e);
    }
    finally
    {
        if (parser != null)
            parser.close();
    }
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:55,代码来源:SOSService.java

示例12: readToken

import org.vast.util.ReaderException; //导入依赖的package包/类
private String readToken() throws IOException
{
    try
    {
        if (tokenIndex < 0 || tokenIndex >= lastSplit.length)
        {
            // read text until next block separator
            tokenBuf.setLength(0);
            blockSepIndex = 0;
            int b;
            do
            {
                b = reader.read();
                if (b < 0)
                    break;
                
                tokenBuf.append((char)b);
                
                // check if we have a block separator
                if (b == blockSep[blockSepIndex])
                    blockSepIndex++;
                else
                    blockSepIndex = 0;
            }
            while (blockSepIndex < blockSep.length);
            
            // remove trailing separator
            if (blockSepIndex == blockSep.length)
                tokenBuf.setLength(tokenBuf.length()-blockSep.length);
            
            // convert to string and trim white spaces if requested
            String recString = tokenBuf.toString();
            if (this.collapseWhiteSpaces)
                recString.trim();
            
            if (recString.isEmpty())
                return null;
            
            lastSplit = recString.split(tokenSep);
            tokenIndex = 0;
        }
        
        // return next token, trimming white spaces if requested
        String nextToken = lastSplit[tokenIndex++];
        if (this.collapseWhiteSpaces)
            nextToken = nextToken.trim();            
        return nextToken;
    }
    catch (IOException e)
    {
        throw new ReaderException("Cannot parse next token", e);
    }
}
 
开发者ID:sensiasoft,项目名称:lib-swe-common,代码行数:54,代码来源:TextDataParser.java


注:本文中的org.vast.util.ReaderException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。