Tabnine Logo
ByteBufferUtils.putString
Code IndexAdd Tabnine to your IDE (free)

How to use
putString
method
in
org.matsim.core.utils.misc.ByteBufferUtils

Best Java code snippets using org.matsim.core.utils.misc.ByteBufferUtils.putString (Showing top 7 results out of 315)

origin: matsim-org/matsim

private void writeSignalSystems(ByteBuffer out){
  out.putInt(this.signalGroups.getSignalGroupDataBySignalSystemId().size());
  for (Id<SignalSystem> systemId : this.signalGroups.getSignalGroupDataBySignalSystemId().keySet()){
    ByteBufferUtils.putString(out, systemId.toString());
    Map<Id<SignalGroup>, SignalGroupData> groups = this.signalGroups.getSignalGroupDataBySystemId(systemId);
    out.putInt(groups.size());
    for (SignalGroupData group : groups.values()){
      ByteBufferUtils.putString(out, group.getId().toString());
      out.putInt(group.getSignalIds().size());
      for (Id<Signal> signalId : group.getSignalIds()){
        ByteBufferUtils.putString(out, signalId.toString());
        SignalData signal = signalSystems.getSignalSystemData().get(systemId).getSignalData().get(signalId);
        ByteBufferUtils.putString(out, signal.getLinkId().toString());
        if (signal.getLaneIds() == null || signal.getLaneIds().isEmpty()){
          out.putInt(0);
          out.putInt(signal.getLaneIds().size());
          for (Id<Lane> laneId : signal.getLaneIds()){
            ByteBufferUtils.putString(out, laneId.toString());
          out.putInt(signal.getTurningMoveRestrictions().size());
          for (Id<Link> outLinkId : signal.getTurningMoveRestrictions()){
            ByteBufferUtils.putString(out, outLinkId.toString());
origin: matsim-org/matsim

private static void writeAgent(AgentSnapshotInfo agInfo, ByteBuffer out) {
  String id = agInfo.getId().toString();
  ByteBufferUtils.putString(out, id);
  Point2D.Double point = OTFServerQuadTree.transform(new Coord(agInfo.getEasting(), agInfo.getNorthing()));
  out.putFloat((float) point.getX());
  out.putFloat((float) point.getY());
  out.putInt(agInfo.getAgentState().ordinal() ) ;
  out.putInt(agInfo.getUserDefined());
  out.putFloat((float)agInfo.getColorValueBetweenZeroAndOne());
}
origin: matsim-org/matsim

private void writeSignalGroupStates(ByteBuffer out){
  out.putInt(this.signalTracker.getSignalGroupEvents().size());
  for (SignalGroupStateChangedEvent e : this.signalTracker.getSignalGroupEvents()){
    ByteBufferUtils.putString(out, e.getSignalSystemId().toString());
    ByteBufferUtils.putString(out, e.getSignalGroupId().toString());
    SignalGroupState state = e.getNewState();
    if (state.equals(SignalGroupState.GREEN)){
      out.putInt(1);
    }
    else if (state.equals(SignalGroupState.RED)){
      out.putInt(0);
    }
    else if (state.equals(SignalGroupState.REDYELLOW)){
      out.putInt(2);
    }
    else if (state.equals(SignalGroupState.YELLOW)){
      out.putInt(3);
    }
    else if (state.equals(SignalGroupState.OFF)){
      out.putInt(4);
    }
    
  }
  this.signalTracker.getSignalGroupEvents().clear();
}
 
origin: matsim-org/matsim

private static void writeAgent(AgentSnapshotInfo pos, ByteBuffer out) {
  String id = pos.getId().toString();
  ByteBufferUtils.putString(out, id);
  Point2D.Double point = OTFServerQuadTree.transform(new Coord(pos.getEasting(), pos.getNorthing()));
  out.putFloat((float) point.getX());
  out.putFloat((float) point.getY());
  out.putInt(pos.getUserDefined());
  out.putFloat((float) pos.getColorValueBetweenZeroAndOne());
  out.putInt(pos.getAgentState().ordinal());
}
origin: matsim-org/matsim

@Override
public void writeConstData(ByteBuffer out) throws IOException {
  out.putInt(this.schedule.getFacilities().size());
  for (TransitStopFacility facility : this.schedule.getFacilities().values()) {
    ByteBufferUtils.putString(out, facility.getId().toString());
    if (facility.getLinkId() != null) {
      // yyyy would most probably make sense to have something that generates coordinates for facilities
      Link link = this.network.getLinks().get( facility.getLinkId() ) ;
      if ( link==null ) {
        log.warn( " link not found; linkId: " + facility.getLinkId() ) ;
        ByteBufferUtils.putString(out,"");
        Point2D.Double point = OTFServerQuadTree.transform(facility.getCoord());
        out.putDouble(point.getX());
        out.putDouble(point.getY());
      } else {
        ByteBufferUtils.putString(out, facility.getLinkId().toString());
        AgentSnapshotInfo ps = agentSnapshotInfoFactory.createAgentSnapshotInfo(Id.create(facility.getId(), Person.class), link, 0.9*link.getLength(), 0) ;
        Point2D.Double point = OTFServerQuadTree.transform(new Coord(ps.getEasting(), ps.getNorthing()));
        out.putDouble(point.getX()) ;
        out.putDouble(point.getY()) ;
      }
    } else {
      ByteBufferUtils.putString(out,"");
      Point2D.Double point = OTFServerQuadTree.transform(facility.getCoord());
      out.putDouble(point.getX());
      out.putDouble(point.getY());
    }
  }
}
origin: matsim-org/matsim

@Override
public void writeConstData(ByteBuffer out) throws IOException {
  String id = this.src.getLink().getId().toString();
  ByteBufferUtils.putString(out, id);
  //subtract minEasting/Northing somehow!
  Point2D.Double.Double linkStart = OTFServerQuadTree.transform(this.src.getLink().getFromNode().getCoord());
  Point2D.Double.Double linkEnd = OTFServerQuadTree.transform(this.src.getLink().getToNode().getCoord());
  out.putFloat((float) linkStart.x); 
  out.putFloat((float) linkStart.y);
  out.putFloat((float) linkEnd.x); 
  out.putFloat((float) linkEnd.y);
    if ( OTFVisConfigGroup.NUMBER_OF_LANES.equals(OTFClientControl.getInstance().getOTFVisConfig().getLinkWidthIsProportionalTo()) ) {
      out.putInt(NetworkUtils.getNumberOfLanesAsInt(0, this.src.getLink()));
    } else if ( OTFVisConfigGroup.CAPACITY.equals(OTFClientControl.getInstance().getOTFVisConfig().getLinkWidthIsProportionalTo()) ) {
      out.putInt( 1 + (int)(2.*this.src.getLink().getCapacity()/3600.) ) ;
      // yyyyyy 3600. is a magic number (the default of the capacity period attribute in Network) but I cannot get to the network (where "capacityPeriod" resides).  
      // Please do better if you know better.  kai, jun'11
    } else {
      throw new RuntimeException("I do not understand.  Aborting ..." ) ;
    }
}
origin: matsim-org/matsim

/**
 * Tests {@link ByteBufferUtils#putString(java.nio.ByteBuffer, String)} and
 * {@link ByteBufferUtils#getString(java.nio.ByteBuffer)}. 
 */
public void testPutGetString() {
  final ByteBuffer buffer = ByteBuffer.allocate(100);
  buffer.putInt(5);
  ByteBufferUtils.putString(buffer, "foo bar");
  buffer.putChar('?');
  ByteBufferUtils.putString(buffer, "Hello World");
  buffer.putChar('!');
  
  buffer.flip();
  
  assertEquals(5, buffer.getInt());
  assertEquals("foo bar", ByteBufferUtils.getString(buffer));
  assertEquals('?', buffer.getChar());
  assertEquals("Hello World", ByteBufferUtils.getString(buffer));
  assertEquals('!', buffer.getChar());
  assertFalse(buffer.hasRemaining());
}

org.matsim.core.utils.miscByteBufferUtilsputString

Javadoc

Writes the given String to the ByteBuffer. First writes the length of the String as int, then writes the single characters. The ByteBuffer's position is incremented according to the length of the String.

Popular methods of ByteBufferUtils

  • getString
    Reads a String from a ByteBuffer. Reads first an int for the length of the String, and then the corr
  • getObject
    Reads a Object (Serializable) from a ByteBuffer. Reads first an int for the length of the Object, an
  • putObject
    Writes the given Serializable to the ByteBuffer. First writes the length of the Serializable as int,

Popular in Java

  • Updating database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now