public void consume(byte[] buffer, int offset, int length) throws IOException { DataInputStream in = new DataInputStream(new ByteArrayInputStream(buffer, offset, length)); do { processOne(in); } while (in.readBoolean()); }
private void runBuild(final MessageHandler msgHandler, CanceledStatus cs) throws Throwable { final File dataStorageRoot = Utils.getDataStorageRoot(myProjectPath); if (dataStorageRoot == null) { msgHandler.processMessage( new CompilerMessage( "build", BuildMessage.Kind.ERROR, "Cannot determine build data storage root for project " + myProjectPath)); return; } if (!dataStorageRoot.exists()) { // invoked the very first time for this project. Force full rebuild myBuildType = BuildType.PROJECT_REBUILD; } final DataInputStream fsStateStream = createFSDataStream(dataStorageRoot); if (fsStateStream != null) { // optimization: check whether we can skip the build final boolean hasWorkToDoWithModules = fsStateStream.readBoolean(); if (myBuildType == BuildType.MAKE && !hasWorkToDoWithModules && scopeContainsModulesOnly(myBuildRunner.getScopes()) && !containsChanges(myInitialFSDelta)) { updateFsStateOnDisk(dataStorageRoot, fsStateStream, myInitialFSDelta.getOrdinal()); return; } } final BuildFSState fsState = new BuildFSState(false); try { final ProjectDescriptor pd = myBuildRunner.load(msgHandler, dataStorageRoot, fsState); myProjectDescriptor = pd; if (fsStateStream != null) { try { try { fsState.load(fsStateStream, pd.getModel(), pd.getBuildRootIndex()); applyFSEvent(pd, myInitialFSDelta); } finally { fsStateStream.close(); } } catch (Throwable e) { LOG.error(e); fsState.clearAll(); } } myLastEventOrdinal = myInitialFSDelta != null ? myInitialFSDelta.getOrdinal() : 0L; // free memory myInitialFSDelta = null; // ensure events from controller are processed after FSState initialization myEventsProcessor.startProcessing(); myBuildRunner.runBuild(pd, cs, myConstantSearch, msgHandler, myBuildType); } finally { saveData(fsState, dataStorageRoot); } }
/** Reads the entire state of the MersenneTwister RNG from the stream */ public void readState(DataInputStream stream) throws IOException { int len = mt.length; for (int x = 0; x < len; x++) mt[x] = stream.readInt(); len = mag01.length; for (int x = 0; x < len; x++) mag01[x] = stream.readInt(); mti = stream.readInt(); __nextNextGaussian = stream.readDouble(); __haveNextNextGaussian = stream.readBoolean(); }
private void processResponse(DataInputStream in) throws IOException { long requestId = in.readLong(); Request r = requests.remove(requestId); if (r == null) { throw new IllegalStateException( "Request " + requestId + " is unknown (last request generated was " + nextRequest.get()); } Object o = null; if (in.readBoolean()) { o = serializerFor(classForName(in.readUTF()), r.getResultDeclaredType()).deserialize(in); } r.set(o); }
/** Reads the suite settings from storage. */ private void readSettings() { byte[] maximums = Permissions.getEmptySet(); byte[] currentLevels = Permissions.getEmptySet(); RandomAccessStream storage = new RandomAccessStream(classSecurityToken); DataInputStream storageStream; int version; int count; permissions = new byte[2][]; permissions[Permissions.MAX_LEVELS] = maximums; permissions[Permissions.CUR_LEVELS] = currentLevels; try { storage.connect(getStorageRoot() + Installer.SETTINGS_FILENAME, Connector.READ); try { storageStream = storage.openDataInputStream(); version = storageStream.readByte(); /* * only version 1 are handled by the method * 0 means that this is a beta version that are not handled * by the method. Note that version number only has to * increase if data has been removed, not if new data has been * added to the end of the file. */ if (version != 1) { System.out.println("Corrupt application settings file."); return; } trusted = storageStream.readBoolean(); pushInterruptSetting = storageStream.readByte(); count = storageStream.readByte(); storageStream.readFully(currentLevels, 0, count); count = storageStream.readByte(); storageStream.readFully(maximums, 0, count); } finally { storage.disconnect(); } } catch (IOException e) { // ignore, old settings files are shorter } }
@SuppressWarnings("rawtypes") private static Object readObjectFromStream(DataInputStream data, Class curClass) throws IOException { if (curClass.equals(Boolean.class)) { return data.readBoolean(); } else if (curClass.equals(Byte.class)) { return data.readByte(); } else if (curClass.equals(Integer.class)) { return data.readInt(); } else if (curClass.equals(String.class)) { return data.readUTF(); } else if (curClass.equals(Double.class)) { return data.readDouble(); } else if (curClass.equals(Float.class)) { return data.readFloat(); } else if (curClass.equals(Long.class)) { return data.readLong(); } else if (curClass.equals(Short.class)) { return data.readShort(); } return null; }
private void processExpressionCommand( Commands.ValueObject valueObject, InvokableValueSender valueSender) throws IOException, CommandException { Integer expressionID = new Integer(in.readInt()); byte cmdType = in.readByte(); ExpressionProcesserController exp = null; switch (cmdType) { case ExpressionCommands.START_EXPRESSION_TREE_PROCESSING: byte trace = in.readByte(); if (trace == ExpressionCommands.TRACE_DEFAULT) exp = new ExpressionProcesserController(server, this); else exp = new ExpressionProcesserController(server, this, trace == ExpressionCommands.TRACE_ON); expressionProcessors.put(expressionID, exp); break; case ExpressionCommands.TRANSFER_EXPRESSION_REQUEST: exp = (ExpressionProcesserController) expressionProcessors.remove(expressionID); sendObject(exp, NOT_A_PRIMITIVE, valueObject, out, true); break; case ExpressionCommands.RESUME_EXPRESSION_REQUEST: Commands.readValue(in, valueObject); exp = (ExpressionProcesserController) getInvokableObject(valueObject); expressionProcessors.put(expressionID, exp); break; case ExpressionCommands.PUSH_EXPRESSION: exp = (ExpressionProcesserController) expressionProcessors.get(expressionID); exp.process(in); break; case ExpressionCommands.SYNC_REQUEST: boolean haveProxies = in.readBoolean(); // See if we expression proxy ids that need to be resolved if (haveProxies) { Commands.readValue(in, valueObject); valueSender.initialize(valueObject); Commands.readArray(in, valueObject.anInt, valueSender, valueObject, false); } exp = (ExpressionProcesserController) expressionProcessors.get(expressionID); if (haveProxies) sendExpressionProxyResolutions(valueObject, (int[]) valueSender.getArray(), exp); if (exp.noErrors()) { valueObject.set(true); // Mark that all is good. Commands.writeValue(out, valueObject, true, true); } else { processExpressionError(exp, valueObject); } break; case ExpressionCommands.PULL_VALUE_REQUEST: haveProxies = in.readBoolean(); // See if we expression proxy ids that need to be resolved if (haveProxies) { Commands.readValue(in, valueObject); valueSender.initialize(valueObject); Commands.readArray(in, valueObject.anInt, valueSender, valueObject, false); } exp = (ExpressionProcesserController) expressionProcessors.get(expressionID); if (haveProxies) sendExpressionProxyResolutions(valueObject, (int[]) valueSender.getArray(), exp); if (exp.noErrors()) { try { Object[] pulledValue = exp.pullValue(); // Send back the command code for pull value. Don't flush. We will flush when all done. if (((Class) pulledValue[1]).isPrimitive()) { int returnTypeID = server.getIdentityID(pulledValue[1]); // Need to tell sendObject the correct primitive type. sendObject(pulledValue[0], returnTypeID, valueObject, out, true, true); } else { sendObject( pulledValue[0], NOT_A_PRIMITIVE, valueObject, out, true, true); // Just send the object back. sendObject knows how to iterpret the type } } catch (NoExpressionValueException e) { sendNoValueErrorCommand(exp, valueObject); } } else processExpressionError(exp, valueObject); break; case ExpressionCommands.END_EXPRESSION_TREE_PROCESSING: exp = (ExpressionProcesserController) expressionProcessors.remove(expressionID); exp.close(); break; } }
protected void loadFromStorage() { DataInputStream inputStream = NvStorage.ReadFileRecord("config", 0); try { accountIndex = inputStream.readInt(); showOfflineContacts = inputStream.readBoolean(); fullscreen = inputStream.readBoolean(); def_profile = inputStream.readInt(); smiles = inputStream.readBoolean(); showTransports = inputStream.readBoolean(); selfContact = inputStream.readBoolean(); collapsedGroups = inputStream.readBoolean(); ignore = inputStream.readBoolean(); eventComposing = inputStream.readBoolean(); gmtOffset = inputStream.readInt(); locOffset = inputStream.readInt(); autoLogin = inputStream.readBoolean(); autoJoinConferences = inputStream.readBoolean(); popupFromMinimized = inputStream.readBoolean(); notifyBlink = inputStream.readBoolean(); memMonitor = inputStream.readBoolean(); font1 = inputStream.readInt(); font2 = inputStream.readInt(); autoFocus = inputStream.readBoolean(); notInListDropLevel = inputStream.readInt(); storeConfPresence = inputStream.readBoolean(); capsState = inputStream.readBoolean(); textWrap = inputStream.readInt(); loginstatus = inputStream.readInt(); msgPath = inputStream.readUTF(); msgLog = inputStream.readBoolean(); msgLogPresence = inputStream.readBoolean(); msgLogConfPresence = inputStream.readBoolean(); msgLogConf = inputStream.readBoolean(); cp1251 = inputStream.readBoolean(); autoAwayDelay = inputStream.readInt(); defGcRoom = inputStream.readUTF(); altInput = inputStream.readBoolean(); isbottom = inputStream.readInt(); confMessageCount = inputStream.readInt(); newMenu = inputStream.readBoolean(); lightState = inputStream.readBoolean(); notifySound = inputStream.readBoolean(); lastMessages = inputStream.readBoolean(); setAutoStatusMessage = inputStream.readBoolean(); autoAwayType = inputStream.readInt(); autoScroll = inputStream.readBoolean(); popUps = inputStream.readBoolean(); showResources = inputStream.readBoolean(); antispam = inputStream.readBoolean(); enableVersionOs = inputStream.readBoolean(); messageLimit = inputStream.readInt(); lang = inputStream.readUTF(); eventDelivery = inputStream.readBoolean(); transliterateFilenames = inputStream.readBoolean(); rosterStatus = inputStream.readBoolean(); queryExit = inputStream.readBoolean(); notifyPicture = inputStream.readBoolean(); showBalloons = inputStream.readBoolean(); userKeys = inputStream.readBoolean(); msglistLimit = inputStream.readInt(); useTabs = inputStream.readBoolean(); autoSubscribe = inputStream.readInt(); useBoldFont = inputStream.readBoolean(); inputStream.close(); } catch (Exception e) { try { if (inputStream != null) inputStream.close(); } catch (IOException ex) { } } lastProfile = profile = def_profile; if (lastProfile == AlertProfile.VIBRA) lastProfile = 0; updateTime(); VirtualList.fullscreen = fullscreen; VirtualList.isbottom = isbottom; VirtualList.memMonitor = memMonitor; VirtualList.showBalloons = showBalloons; VirtualList.userKeys = userKeys; }