Package org.xmlBlaster.util.qos

Examples of org.xmlBlaster.util.qos.ClientProperty


            continue;
         Object val = map.get(key);
         if (val == null)
            continue;
         if (val instanceof String) {
            ClientProperty prop = null;
            if (((String)key).equalsIgnoreCase(ReplicationConstants.OLD_CONTENT_ATTR)) {
               prop = new ClientProperty((String)key, null, Constants.ENCODING_FORCE_PLAIN, (String)val);
            }
            else
               prop = new ClientProperty((String)key, null, null, (String)val);
            storeProp(prop, destinationMap, destinationList);
         }
         else if (val instanceof ClientProperty) {
            storeProp((ClientProperty)val, destinationMap, destinationList);
         }
View Full Code Here


      // remove entry having the new name (if any)
      findStringEntry(newName, list, true);
      map.remove(newName);
      String listEntryName = findStringEntry(oldName, list, true);
      if (listEntryName != null) {
         ClientProperty oldEntry = (ClientProperty)map.remove(oldName);
         if (oldEntry == null)
            throw new Exception("The renaming of '" + oldName + "' to '" + newName + "' failed because the old entry was not found in the map");
         //ClientProperty newProp = new ClientProperty(newName, oldEntry.getType(), oldEntry.getEncoding(), oldEntry.getValueRaw());
         ClientProperty newProp = new ClientProperty(newName, oldEntry.getType(), oldEntry.getEncoding());
         newProp.setValueRaw(oldEntry.getValueRaw());
         map.put(newName, newProp);
         list.add(newName);
      }
   }
View Full Code Here

   
    * @param key the key of the attribute
    * @return the ClientProperty object associated with the key, or if none found, null is returned.
    */
   public ClientProperty getAttribute(String key) {
      ClientProperty prop = (ClientProperty)this.attributes.get(key);
      if (!this.caseSensitive && prop == null) {
         prop = (ClientProperty)this.attributes.get(key.toLowerCase());
         if (prop == null)
            prop = (ClientProperty)this.attributes.get(key.toUpperCase());
      }
View Full Code Here

   /**
    * Stores the String as a new value. The passed String is directly transformed into a ClientProperty object.
    * @param value the value to store as an attribute.
    */
   public void setAttribute(String key, String value) {
      ClientProperty prop = new ClientProperty(key, null, null, value);
      SqlRow.storeProp(prop, this.attributes, this.attributeKeys);
   }
View Full Code Here

      addProps(map, this.attributes, this.attributeKeys);
   }
  
  
   public ClientProperty getColumn(String key) {
      ClientProperty prop = (ClientProperty)this.columns.get(key);
      if (!this.caseSensitive && prop == null) {
         prop = (ClientProperty)this.columns.get(key.toLowerCase());
         if (prop == null)
            prop = (ClientProperty)this.columns.get(key.toUpperCase());
      }
View Full Code Here

      }
      else {
         Iterator iter = this.columnKeys.iterator();
         while (iter.hasNext()) {
            Object key = iter.next();
            ClientProperty prop = (ClientProperty)this.columns.get(key);
            sb.append(prop.toXml(extraOffset + "  ", COL_TAG, forceReadable));
            if (doTruncate && sb.length() > SqlInfo.MAX_BUF_SIZE) {
               sb.append(" ...");
               return sb.toString();
            }
         }
      }
     
      Iterator iter = this.attributeKeys.iterator();
      while (iter.hasNext()) {
         Object key = iter.next();
         ClientProperty prop = (ClientProperty)this.attributes.get(key);
         sb.append(prop.toXml(extraOffset + "  ", SqlInfoParser.ATTR_TAG));
         if (doTruncate && sb.length() > SqlInfo.MAX_BUF_SIZE) {
            sb.append(" ...");
            return sb.toString();
         }
      }
View Full Code Here

      this.glob = Global.instance();

   }

   public void testClientProperty() throws Exception {
      ClientProperty clientProperty = new ClientProperty("StringKey", null, null);
      assertEquals("", "StringKey", clientProperty.getName());
      assertEquals("", null, clientProperty.getType());
      assertEquals("", null, clientProperty.getEncoding());
      assertEquals("", false, clientProperty.isBase64());
      assertEquals("", null, clientProperty.getValueRaw());
      assertEquals("", null, clientProperty.getStringValue());
      assertEquals("", null, clientProperty.getValueRaw());

      String xml = clientProperty.toXml();
      assertXpathExists("/clientProperty[@name='StringKey']", xml);
      System.out.println(xml);
   }
View Full Code Here

      System.out.println(xml);
   }

   public void testClientPropertyEncoding() throws Exception {
      {
         ClientProperty clientProperty = new ClientProperty("StringKey", "String", Constants.ENCODING_BASE64);
         assertEquals("", "StringKey", clientProperty.getName());
         assertEquals("", "String", clientProperty.getType());
         assertEquals("", Constants.ENCODING_BASE64, clientProperty.getEncoding());
         assertEquals("", true, clientProperty.isBase64());
         assertEquals("", null, clientProperty.getStringValue());
         assertEquals("", null, clientProperty.getValueRaw());

         String xml = clientProperty.toXml();
         assertXpathExists("/clientProperty[@name='StringKey']", xml);
         assertXpathExists("/clientProperty[@type='String']", xml);
         assertXpathExists("/clientProperty[@encoding='"+Constants.ENCODING_BASE64+"']", xml);
         System.out.println(xml);
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='StringKey' type='String' encoding='base64'/>",
                        xml);

         clientProperty.setValue("BlaBlaBla");
         xml = clientProperty.toXml();
         assertEquals("Base64?", "QmxhQmxhQmxh", clientProperty.getValueRaw());
         assertEquals("", "BlaBlaBla", clientProperty.getStringValue());
         System.out.println(xml);
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='StringKey' type='String' encoding='base64'>QmxhQmxhQmxh</clientProperty>",
                        xml);
         try {
            assertEquals("", 99, clientProperty.getIntValue());
            fail("String to int not possible");
         }
         catch(java.lang.NumberFormatException e) {
            System.out.println("OK Expected exception NumberFormatException");
         }
View Full Code Here

   }

   public void testClientPropertyCtorEncoding() throws Exception {
      {
         String value = "Bla<<";
         ClientProperty clientProperty = new ClientProperty("StringKey",
                                          ClientProperty.getPropertyType(value), null, value);
         assertEquals("", "StringKey", clientProperty.getName());
         assertEquals("", null, clientProperty.getType()); // defaults to String
         assertEquals("", Constants.ENCODING_BASE64, clientProperty.getEncoding());
         assertEquals("", true, clientProperty.isBase64());
         assertEquals("", value, clientProperty.getStringValue());
         //assertEquals("", null, clientProperty.getValueRaw());

         String xml = clientProperty.toXml();
         assertXpathExists("/clientProperty[@name='StringKey']", xml);
         assertXpathExists("/clientProperty[@encoding='"+Constants.ENCODING_BASE64+"']", xml);
         assertXMLEqual("comparing test xml to control xml",
                        "<clientProperty name='StringKey' encoding='base64'>QmxhPDw=</clientProperty>",
                        xml);
View Full Code Here

         System.out.println(xml);
      }
   }

   public void testClientPropertyAutoEncoding() throws Exception {
      ClientProperty clientProperty = new ClientProperty("StringKey", "", "");
      assertEquals("", "StringKey", clientProperty.getName());
      assertEquals("", "", clientProperty.getType());
      assertEquals("", "", clientProperty.getEncoding());
      assertEquals("", null, clientProperty.getStringValue());
      assertEquals("", null, clientProperty.getValueRaw());

      clientProperty.setValue("Bla<BlaBla");
      assertEquals("", Constants.ENCODING_BASE64, clientProperty.getEncoding());
      String xml = clientProperty.toXml();
      System.out.println(xml);
      assertEquals("Base64?", "QmxhPEJsYUJsYQ==", clientProperty.getValueRaw());
      assertEquals("", "Bla<BlaBla", clientProperty.getStringValue());
      System.out.println(xml);

      clientProperty.setValue("Bla]]>BlaBla");
      assertEquals("", Constants.ENCODING_BASE64, clientProperty.getEncoding());
      xml = clientProperty.toXml();
      //assertEquals("Base64?", "QmxhPD5CbGFCbGE=", clientProperty.getValueRaw());
      assertEquals("", "Bla]]>BlaBla", clientProperty.getStringValue());
      System.out.println(xml);
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.qos.ClientProperty

Copyright © 2018 www.massapicom. 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.