コード例 #1
0
 void serv(int i) {
   try {
     S = new DatagramSocket(i);
     S.setSoTimeout(5000);
   } catch (Exception exception) {
     exception.printStackTrace();
     if (S != null)
       try {
         S.close();
       } catch (Exception exception2) {
       }
     return;
   }
   System.out.println(DF.format(new Date()) + "Waiting connections ...");
   do
     try {
       buf = new byte[256];
       P = new DatagramPacket(buf, buf.length);
       S.receive(P);
       Connection connection =
           (Connection) Connections.get(P.getAddress().toString() + P.getPort());
       if (connection == null) {
         System.out.println(
             DF.format(new Date())
                 + "Connect from "
                 + " ("
                 + P.getAddress().getHostAddress()
                 + ")");
         connection = new Connection(this, P);
         Connections.put(P.getAddress().toString() + P.getPort(), connection);
         connection.start();
       } else {
         connection.packet(P);
       }
     } catch (Exception exception1) {
     }
   while (true);
 }
コード例 #2
0
  @Override
  public void write(IFeedRecords records) {

    String sTitle = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.title"));
    String sDescription =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.description"));
    String sKeyword = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.keyword"));
    String sModified =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.modified"));
    String sPublisher =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.publisher"));
    String sPerson =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.contactPoint"));
    String sMbox = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.mbox"));
    String sIdentifier =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.identifier"));
    String sAccessLevel =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.accessLevel"));
    String sAccessLevelComment =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.accessLevelComment"));
    String sBureauCode =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.bureauCode"));
    String sProgramCode =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.programCode"));
    String sDataDictionary =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.dataDictionary"));
    String sAccessUrl =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.accessURL"));
    String sWebService =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.webService"));
    String sFormat = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.format"));
    String sLicense = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.license"));
    String sSpatial = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.spatial"));
    String sTemporal =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.temporal"));

    defaultValues.put("title", sTitle);
    defaultValues.put("description", sDescription);

    defaultValues.put("keyword", sKeyword);
    defaultValues.put("modified", sModified);

    defaultValues.put("publisher", sPublisher);
    defaultValues.put("contactPoint", sPerson);
    defaultValues.put("mbox", sMbox);
    defaultValues.put("identifier", "");
    defaultValues.put("accessLevel", sAccessLevel);
    defaultValues.put("accessLevelComment", sAccessLevelComment);

    defaultValues.put("bureauCode", sBureauCode);
    defaultValues.put("programCode", sProgramCode);

    defaultValues.put("dataDictionary", sDataDictionary);
    defaultValues.put("accessURL", sAccessUrl);
    defaultValues.put("webService", sWebService);
    defaultValues.put("format", sFormat);
    defaultValues.put("spatial", sSpatial);
    defaultValues.put("temporal", "");

    println("[");
    levelUp();

    println("{");
    levelUp();

    printArg("title", sTitle, true);
    printArg("description", sDescription, true);
    printArg2("keyword", sKeyword, true);
    if (sModified.length() > 0) {
      printArg("modified", sModified, true);
    } else {
      printArg("modified", DF.format(new Date()), true);
    }
    printArg("publisher", sPublisher, true);
    printArg("contactPoint", sPerson, true);
    printArg("mbox", sMbox, true);
    printArg("identifier", sIdentifier, true);
    printArg("accessLevel", sAccessLevel, true);
    printArg("accessLevelComment", sAccessLevelComment, true);
    printArg2("bureauCode", sBureauCode, true);
    printArg2("programCode", sProgramCode, true);
    if (sDataDictionary.length() > 0) {
      printArg("dataDictionary", sDataDictionary, true);
    }

    if (sAccessUrl.length() > 0) {
      printLinkArg("accessURL", sAccessUrl, true);
    } else if (query != null) {
      printLinkArg("accessURL", query.getRssProviderUrl(), true);
    } else {
      printLinkArg("accessURL", "", true);
    }

    if (sWebService.length() > 0) {
      printLinkArg("webService", sWebService, true);
    } else if (query != null) {
      printLinkArg("webService", query.getRssSourceUrl(), true);
    } else {
      printArg("webService", "", true);
    }

    printArg("format", "application/json", true);
    printArg("license", sLicense, true);
    printArg("spatial", sSpatial, true);
    printArg("temporal", sTemporal, false);

    levelDown();
    println(records != null && records.size() > 0 ? "}," : "}");
    if (records != null) {
      printRecords(records, true);
    }

    levelDown();
    println("]");
  }