Examples of Counter


Examples of org.need4steed.cccount.Counter

public class CounterTest {

  @Test
  public void test() {
    String s ="ab弓都𪛖\u9fa5弓t\u9fa5M";
    Counter ct = new Counter();
    ct.Process(s);
    assertEquals(10  , ct.GetNChars());
    assertEquals(6, ct.GetNCjks());
    assertEquals(4, ct.GetNDistinguishable());
    String[] res= {"弓\t2","\u9fa5\t2","都\t1","𪛖\t1"};
    int i = 0;
    for(String el:ct)
    {
      System.out.println(el);
      assertEquals(res[i], el);
      i++;
    }
   
    assertEquals(4,i);
    StringWriter w = new StringWriter();
    try {
      ct.Output(w);
      assertEquals(res[3], w.toString().split("\n")[3]);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here

Examples of org.springframework.osgi.extender.internal.util.concurrent.Counter

  protected void waitOnContextCreation(BundleContext context, String forBundleWithSymbolicName, long timeout) {
    // translate from seconds to milliseconds
    long time = timeout * SECOND;

    // use the counter to make sure the threads block
    final Counter counter = new Counter("waitForContext on bnd=" + forBundleWithSymbolicName);

    counter.increment();

    String filter = "(org.springframework.context.service.name=" + forBundleWithSymbolicName + ")";

    ServiceListener listener = new ServiceListener() {

      public void serviceChanged(ServiceEvent event) {
        if (event.getType() == ServiceEvent.REGISTERED)
          counter.decrement();
      }
    };

    OsgiListenerUtils.addServiceListener(context, listener, filter);

    if (logger.isDebugEnabled())
      logger.debug("Start waiting for Spring/OSGi bundle=" + forBundleWithSymbolicName);

    try {
      if (counter.waitForZero(time)) {
        waitingFailed(forBundleWithSymbolicName);
      }
      else if (logger.isDebugEnabled()) {
        logger.debug("Found applicationContext for bundle=" + forBundleWithSymbolicName);
      }
View Full Code Here

Examples of org.springframework.xd.analytics.metrics.core.Counter

   * Retrieve information about a specific counter.
   */
  @ResponseBody
  @RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
  public CounterResource display(@PathVariable("name") String name) {
    Counter c = repository.findOne(name);
    if (c == null) {
      throw new NoSuchMetricException(name, "There is no counter named '%s'");
    }
    return counterResourceAssembler.toResource(c);
  }
View Full Code Here

Examples of org.wso2.carbon.bam.data.publisher.activity.service.Counter

                        if (value != null) {
                            if (value instanceof Counter) {
                                ((Counter) value).increment();
                            }
                        } else {
                            Counter messageCounter = new Counter();
                            messageCounter.increment();
                            messageContext.getConfigurationContext()
                                    .setProperty(ActivityPublisherConstants.BAM_MESSAGE_COUNT, messageCounter);
                        }
                        PublisherUtils.getEventPayload(messageContext, messageContext.getConfigurationContext()
                                .getAxisConfiguration(), messageID, activityID, messageContext.getAxisService().getName(),
View Full Code Here

Examples of org.wso2.carbon.bam.data.publisher.clientstats.Counter

    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {

        String service = "";
        String operation = "";
        Counter counter = new Counter();
        if (msgContext.getConfigurationContext().getProperty(
                ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_PROPERTY) != null) {
            service = msgContext.getConfigurationContext().getProperty(
                    ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_PROPERTY)
                    .toString();
        } else {
            log.error("ServiceName property not found");
        }
        if (msgContext.getConfigurationContext().getProperty(
                ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_PROPERTY) != null) {
            operation = msgContext.getConfigurationContext().getProperty(
                    ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_PROPERTY)
                    .toString();
        } else {
            log.error("OperationName property not found");
        }
       
        // Increment the global fault count
        Object globalFaultCounterObject = msgContext
                .getProperty(ClientStatisticsPublisherConstants.BAM_USER_DEFINED_GLOBAL_FAULT_COUNTER_PROPERTY);
        if (globalFaultCounterObject == null) {
            log
                    .warn(ClientStatisticsPublisherConstants.BAM_USER_DEFINED_GLOBAL_FAULT_COUNTER_PROPERTY
                            + " is null");
        } else {
            if (globalFaultCounterObject instanceof Counter) {
                counter.increment(((Counter) globalFaultCounterObject).getCount());
            }
        }

        // Increment the service fault count
        if (service != null) {
            Object serviceFaultCountObj = msgContext
                    .getConfigurationContext()
                    .getProperty(
                            ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_FAULT_COUNTER_PROPERTY);
            if (serviceFaultCountObj != null) {
                if (serviceFaultCountObj instanceof Counter) {
                    counter.increment(((Counter) serviceFaultCountObj).getCount());
                }
            } else {
                counter.increment();
                msgContext
                        .getConfigurationContext()
                        .setProperty(
                                ClientStatisticsPublisherConstants.BAM_USER_DEFINED_SERVICE_FAULT_COUNTER_PROPERTY,
                                counter);
            }
        }

        if (operation != null) {
            Object operationFaultCountObject = msgContext
                    .getConfigurationContext()
                    .getProperty(
                            ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_FAULT_COUNTER_PROPERTY);
            if (operationFaultCountObject != null) {
                if (operationFaultCountObject instanceof Counter) {
                    counter.increment(((Counter) operationFaultCountObject).getCount());
                }
            } else {
                counter.increment();
                msgContext
                        .getConfigurationContext()
                        .setProperty(
                                ClientStatisticsPublisherConstants.BAM_USER_DEFINED_OPERATION_FAULT_COUNTER_PROPERTY,
                                counter);
View Full Code Here

Examples of powercrystals.minefactoryreloaded.circuits.digital.Counter

    MFRRegistry.registerRedNetLogicCircuit(new AdderDigitalFull());
    MFRRegistry.registerRedNetLogicCircuit(new AdderDigitalHalf());
    MFRRegistry.registerRedNetLogicCircuit(new And2());
    MFRRegistry.registerRedNetLogicCircuit(new And3());
    MFRRegistry.registerRedNetLogicCircuit(new And4());
    MFRRegistry.registerRedNetLogicCircuit(new Counter());
    MFRRegistry.registerRedNetLogicCircuit(new DecomposeIntToDecimal());
    MFRRegistry.registerRedNetLogicCircuit(new Delay());
    MFRRegistry.registerRedNetLogicCircuit(new DeMux16Analog());
    MFRRegistry.registerRedNetLogicCircuit(new DeMux4());
    MFRRegistry.registerRedNetLogicCircuit(new Equal());
View Full Code Here

Examples of solver.constraints.nary.automata.FA.utils.Counter

        return (pi == null) ? null :
                new CostAutomaton(pi, tmp);
    }

    public static ICostAutomaton makeSingleResource(IAutomaton pi, int[][] costs, int inf, int sup) {
        ICounter c = new Counter(costs, inf, sup);
        ArrayList<ICounter> tmp = new ArrayList<ICounter>();
        tmp.add(c);
        return (pi == null) ? null :
                new CostAutomaton(pi, tmp);
    }
View Full Code Here

Examples of stallone.util.Counter

    int dim;
    IDoubleArray prePoint;

    public GridPointIterator(int[] sizes, IDoubleArray[] pointPositions)
    {
         count = new Counter(Ints.create.arrayFrom(sizes));
         dim = sizes.length;
         prePoint = Doubles.create.array(sizes.length);
    }
View Full Code Here

Examples of stateandbehavior.Counter

@SuppressWarnings("all")
public class CounterTest extends TestCase {
  private Counter counter;
 
  private Counter _init_counter() {
    Counter _counter = new Counter(1, 3);
    return _counter;
  }
View Full Code Here

Examples of util.Counter

            return;

         StringWriter sw = new StringWriter();
         PrintWriter writer = new PrintWriter(sw);
        
         Counter counter = (Counter)filterConfig.getServletContext().getAttribute("hitCounter");
         writer.println();
         writer.println("=======================================================");
         writer.println("The number of hits is: " + counter.incCounter());
         writer.println("=======================================================");

         // Log the resulting string
         writer.flush();
         filterConfig.getServletContext().log(sw.getBuffer().toString());
        
         PrintWriter out = response.getWriter();
         CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse)response);
         chain.doFilter(request, wrapper);
         int index = wrapper.getData().indexOf("</body></html>");
         out.write(wrapper.getData().substring(0, index-1));
         out.println("<center>You are visitor number <font color=\"red\">" + counter.getCounter() + "</font></center>");
         out.println("</body></html>");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.