A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Code Examples of Source


		
//		StringReader strReader = new St
		
		
		outputDocument = new OutputDocument(htmlText);
		Source formFieldsSource = new Source(htmlText);
		
//		formFieldsSource.findAllElements()
		
		FormFields formFields = formFieldsSource.findFormFields();
		

		if (logger.isInfoEnabled()) {
			logger
					.info("transformation(File, BigDecimal) - formFields.size() : " + formFields.size()); //$NON-NLS-1$

View Full Code Here


		FileInputStream inputStream = new FileInputStream(file);
		
		String htmlText = StreamUtils.getString(inputStream);
		
		outputDocument = new OutputDocument(htmlText);
		Source formFieldsSource = new Source(htmlText);
				
		FormFields formFields = formFieldsSource.findFormFields();
		

		if (logger.isInfoEnabled()) {
			logger
					.info("transformation(File, BigDecimal, TransactionContext, FormAttrDAO) - formFields.size() : " + formFields.size()); //$NON-NLS-1$

View Full Code Here


    }

    public void testToDomSourceByCustomSource() throws Exception {
        XmlConverter conv = new XmlConverter();

        Source dummy = new Source() {
            public String getSystemId() {
                return null;
            }

            public void setSystemId(String s) {

View Full Code Here


            tmp = "<body>" + inputHTML + "</body>";
        } else {
            tmp = inputHTML;
        }

        final Source source = new Source(tmp);

        // The DOMFragmentParser generates a HTML and a BODY element which are
        // of no interest for us. We select the HTMLBodyElement which will then
        // be consumed in the validateHtml method. It is the starting root element
        // of the HTML fragment.
        linkToDest.clear();

        final List<Result> results = validateHtml(source.getChildElements().get(0), source);
        for (Result result : results) {
            if (Result.Type.ERROR.equals(result.getType())) {
                evh.addError(result);
            } else if (Result.Type.WARNING.equals(result.getType())) {
                evh.addWarning(result);

View Full Code Here


            HtmlTagAttributeVisitor... visitors) {
        if (attributesToVisit == null || attributesToVisit.isEmpty() || visitors == null || visitors.length == 0) {
            return htmlContent;
        }

        Source source = new Source(htmlContent);
        OutputDocument document = new OutputDocument(source);

        for (Map.Entry<String, Set<String>> tag : attributesToVisit.entrySet()) {
            List<StartTag> tags = source.getAllStartTags(tag.getKey());
            for (StartTag startTag : tags) {
                final Attributes attributes = startTag.getAttributes();
                for (String attrName : tag.getValue()) {
                    Attribute attribute = attributes.get(attrName);
                    if (attribute != null) {

View Full Code Here


        }

        long timer = System.currentTimeMillis();
        boolean modified = false;

        Source src = new Source(content);
        OutputDocument out = new OutputDocument(src);
        for (String filteredTagName : filteredTags) {
            for (StartTag startTag : src.getAllStartTags(filteredTagName)) {
                if (startTag.getTagType() == StartTagType.NORMAL) {
                    Element element = startTag.getElement();
                    EndTag endTag = element.getEndTag();
                    if (removeContentBetweenTags && endTag != null) {
                        out.remove(element);

View Full Code Here


        
        String output = service.externalize(source, serverUrl);
        
        assertTrue("Output is empty", StringUtils.isNotEmpty(output));
        
        Source src = new Source(output);

        // check URLs
        List<StartTag> linkStartTags = src.getAllStartTags(HTMLElementName.A);
        for (StartTag startTag : linkStartTags) {
            String href = startTag.getAttributeValue("href");
            assertTrue("The URL was not rewritten correctly: " + href, href == null || !href.startsWith("/"));
        }
    }

View Full Code Here


    }

    protected String processCss(String previousOut, String serverUrl, HttpServletRequest request,
            HttpServletResponse response) {

        Source source = new Source(previousOut);
        OutputDocument document = new OutputDocument(source);
        StringBuilder sb = new StringBuilder();
        List<StartTag> linkStartTags = source.getAllStartTags(HTMLElementName.LINK);
        for (StartTag linkTag : linkStartTags) {
            Attributes attributes = linkTag.getAttributes();
            String rel = attributes.getValue("rel");
            if (rel == null || !"stylesheet".equalsIgnoreCase(rel)) {
                continue;

View Full Code Here


            // replace /live/ by /default/ in href and src attributes as it represents same image
            if(original.contains("/files/"+Constants.EDIT_WORKSPACE+"/")||amendment.contains("/files/"+Constants.EDIT_WORKSPACE+"/")) {
                original = original.replaceAll("/"+ Constants.LIVE_WORKSPACE+"/","/"+Constants.EDIT_WORKSPACE+"/");
                amendment = amendment.replaceAll("/"+ Constants.LIVE_WORKSPACE+"/","/"+Constants.EDIT_WORKSPACE+"/");
            }
            original = new SourceFormatter(new Source(original)).toString();
            amendment = new SourceFormatter(new Source(amendment)).toString();
            final ContentHandler postProcess = filter.xsl(result, "jahiahtmlheader.xsl");

            final Locale locale = Locale.ENGLISH;
            final String prefix = "diff";

View Full Code Here


            //Search for primary field if present
            try {
                String itemName = getPrimaryNodeType().getPrimaryItemName();
                if (itemName != null) {
                    String s = getProperty(itemName).getValue().getString();
                    title = new TextExtractor(new Source(s != null ? s : getName())).toString();
                }
            } catch (RepositoryException e1) {
                title = null;
            }
        }

View Full Code Here


    public String execute(String previousOut, RenderContext renderContext, Resource resource, RenderChain chain)
            throws Exception {

        long timer = System.currentTimeMillis();
        
        final SourceFormatter sourceFormatter = new SourceFormatter(new Source(previousOut));
        sourceFormatter.setIndentString("  ");

        String out = sourceFormatter.toString();
        
        if (logger.isDebugEnabled()) {

View Full Code Here



        OMElement sourceEle = elem.getFirstChildWithName(SOURCE_Q);
        if (sourceEle == null) {
            handleException("source element is mandatory");
        }
        Source source = new Source();
        enrich.setSource(source);

        OMElement targetEle = elem.getFirstChildWithName(TARGET_Q);
        if (targetEle == null) {
            handleException("target element is mandatory");

View Full Code Here



        OMElement sourceEle = elem.getFirstChildWithName(SOURCE_Q);
        if (sourceEle == null) {
            handleException("source element is mandatory");
        }
        Source source = new Source();
        enrich.setSource(source);

        OMElement targetEle = elem.getFirstChildWithName(TARGET_Q);
        if (targetEle == null) {
            handleException("target element is mandatory");

View Full Code Here


    mapper = getMapper("inheritanceHints.xml");
  }

  @Test
  public void test_simple() {
    Source source = new Source();
    HashSet<Base> set = new HashSet<Base>();
    set.add(new BaseA());
    set.add(new BaseB());
    source.setSet(set);

    Target result = mapper.map(source, Target.class);

    assertNotNull(result);
    assertNotNull(result.getSet());

View Full Code Here


         String content = localData.getSource();
         Calendar lastModified = Calendar.getInstance();
         lastModified.setTime(localData.getLastModified());

         //
         Source source = new Source(gadget.getName());
         source.setMimeType(LocalGadgetData.GADGET_MIME_TYPE);
         source.setLastModified(lastModified);
         source.setTextContent(content);

         //
         return source;
      }
      else

View Full Code Here


					for (int k = 0; k < tagCount; k++) {
						Tag tag = TagScanner.scanTag(rawData);
						tagList.addTag(tag);
					}
					ClientID client_id = new ClientID(clientID);
					Source source = new Source(client_id, tagList);

					source.setAddress(new IPAddress(packet.getAddress()));
					source.setUDPPort(packet.getAddress().getPort());

					KadContact contact = routing_table.getContact(client_id);
					if (contact != null)
						source.setTCPPort(contact.getTCPPort());

					list.add(source);
				}

				boolean source_load = false;

				for (Source source : list) {
					boolean isSourcePublish = false;
					isSourcePublish = source.getTagList()
							.hasTag(TAG_SOURCETYPE);
					if (isSourcePublish) {
						indexer.addFileSource(targetID, source);
						source_load = true;
					} else
						indexer.addFileSource(targetID, source);
				}
				KadPacket response = null;
				if (source_load)
					response = PacketFactory.getPublishResPacket(targetID,
							indexer.getFileSourcesLoad());
				else
					response = PacketFactory.getPublishResPacket(targetID,
							indexer.getKeywordLoad());
				_network_manager.sendKadPacket(response, sender_address,
						sender_port);

			} else if (packetOPCode == KADEMLIA_PUBLISH_RES) {
				byte targetID[] = new byte[16];
				rawData.get(targetID);
				int load = byteToInt(rawData.get());
				publisher.processGenericResponse(new ClientID(targetID), load);
			} else if (packetOPCode == KADEMLIA_SEARCH_NOTES_REQ) {
				byte[] targetID = new byte[16];
				rawData.get(targetID);
				List<Source> source_list = indexer.getNoteSources(new Int128(
						targetID));
				KadPacket response = PacketFactory.getNotesRes(new Int128(
						targetID), source_list);
				_network_manager.sendKadPacket(response, sender_address,
						sender_port);
			} else if (packetOPCode == KADEMLIA_SEARCH_NOTES_RES) {
				byte[] noteID = new byte[16];
				rawData.get(noteID);
				int resultCount = shortToInt(rawData.getShort());
				List<Source> sourceList = new LinkedList<Source>();

				for (int i = 0; i < resultCount; i++) {
					byte[] clientID = new byte[16];
					rawData.get(clientID);
					Convert.updateSearchID(clientID);
					int tagCount = shortToInt(rawData.get());
					TagList tagList = new TagList();
					for (int k = 0; k < tagCount; k++) {
						Tag tag = TagScanner.scanTag(rawData);
						tagList.addTag(tag);
					}
					Source source = new Source(new ClientID(clientID), tagList);
					source.setAddress(new IPAddress(packet.getAddress()));
					source.setUDPPort(packet.getAddress().getPort());
					KadContact contact = RoutingTable.getSingleton()
							.getContact(new ClientID(clientID));
					if (contact != null)
						source.setTCPPort(contact.getTCPPort());
					sourceList.add(source);
				}
				search.processResults(packet.getAddress(), new Int128(noteID),
						sourceList);
			} else if (packetOPCode == KADEMLIA_PUBLISH_NOTES_REQ) {
				byte[] noteID = new byte[16];
				rawData.get(noteID);
				byte[] publisherID = new byte[16];
				rawData.get(publisherID);
				int tagCount = byteToInt(rawData.get());
				TagList tagList = new TagList();
				for (int i = 0; i < tagCount; i++) {
					Tag tag = TagScanner.scanTag(rawData);
					tagList.addTag(tag);
				}
				ClientID publisher_id = new ClientID(publisherID);
				Source source = new Source(publisher_id, tagList);
				source.setAddress(new IPAddress(packet.getAddress()));
				source.setUDPPort(packet.getAddress().getPort());

				KadContact contact = routing_table.getContact(publisher_id);
				if (contact != null)
					source.setTCPPort(contact.getTCPPort());

				indexer.addNoteSource(new Int128(noteID), source);
				KadPacket response = PacketFactory.getPublishNotesRes(
						new Int128(noteID), indexer.getNoteLoad());
				_network_manager.sendKadPacket(response, sender_address,
						sender_port);

			} else if (packetOPCode == KADEMLIA_PUBLISH_NOTES_RES) {
				byte[] noteID = new byte[16];
				rawData.get(noteID);
				int load = byteToInt(rawData.get());
				publisher.processNoteResponse(new Int128(noteID), load);
			} else if (packetOPCode == KADEMLIA_SEARCH_REQ) {
				byte targetID[] = new byte[16];
				rawData.get(targetID);
				boolean sourceSearch = false;
				if (rawData.limit() == 17)
					if (rawData.get() == 1)
						sourceSearch = true;
				List<Source> source_list;

				if (sourceSearch)
					source_list = indexer.getFileSources(new Int128(targetID));
				else
					source_list = indexer
							.getKeywordSources(new Int128(targetID));
				KadPacket response = PacketFactory.getSearchResPacket(
						new Int128(targetID), source_list);
				_network_manager.sendKadPacket(response, sender_address,
						sender_port);
			} else if (packetOPCode == KADEMLIA_SEARCH_RES) {
				byte targetID[] = new byte[16];
				rawData.get(targetID);
				int resultCount = shortToInt(rawData.getShort());

				List<Source> sourceList = new LinkedList<Source>();

				for (int i = 0; i < resultCount; i++) {
					byte[] contactID = new byte[16];
					rawData.get(contactID);
					int tagCount = byteToInt(rawData.get());
					TagList tagList = new TagList();
					for (int k = 0; k < tagCount; k++) {
						try {
							Tag tag = TagScanner.scanTag(rawData);
							if (tag == null)
								continue;

							tagList.addTag(tag);
						} catch (Throwable t) {
							t.printStackTrace();
						}
					}
					ClientID client_id = new ClientID(contactID);
					Source source = new Source(client_id, tagList);
					KadContact contact = routing_table.getContact(client_id);
					if (contact != null) {
						source.setUDPPort(contact.getUDPPort());
						source.setTCPPort(contact.getTCPPort());
					}
					sourceList.add(source);
				}
				search.processResults(packet.getAddress(),
						new Int128(targetID), sourceList);
			} else if (packetOPCode == KADEMLIA_FIREWALLED_REQ) {
				int tcpPort = shortToInt(rawData.getShort());
				firewallChecker.processFirewallRequest(packet.getAddress(),
						tcpPort);
			} else if (packetOPCode == KADEMLIA_FIREWALLED_RES) {
				byte[] address = new byte[4];
				rawData.get(address);
				firewallChecker.porcessFirewallResponse(packet.getAddress(),
						new IPAddress(address));
			} else if (packetOPCode == KADEMLIA2_HELLO_REQ) {
				byte[] client_id_raw = new byte[16];
				rawData.get(client_id_raw);
				ClientID clientID = new ClientID(client_id_raw);
				int tcpPort = shortToInt(rawData.getShort());
				byte version = rawData.get();
				byte tag_count = rawData.get();
				List<Tag> tag_list = new LinkedList<Tag>();
				for (byte i = 0; i < tag_count; i++) {
					Tag tag = TagScanner.scanTag(rawData);
					if (tag == null)
						throw new CorruptedPacketException();
					tag_list.add(tag);
				}

				KadContact contact = routing_table.getContact(clientID);
				if (contact != null) {
					contact.setTCPPort(tcpPort);
					contact.setUDPPort(packet.getAddress().getPort());
					contact.setVersion(version);
				}

				KadPacket response = PacketFactory
						.getHello2ResPacket(TagList.EMPTY_TAG_LIST);
				_network_manager.sendKadPacket(response, sender_address,
						sender_port);
			} else if (packetOPCode == KADEMLIA2_HELLO_RES) {
				byte[] client_id_raw = new byte[16];
				rawData.get(client_id_raw);
				ClientID clientID = new ClientID(client_id_raw);
				int tcpPort = shortToInt(rawData.getShort());
				byte version = rawData.get();
				byte tag_count = rawData.get();
				List<Tag> tag_list = new LinkedList<Tag>();

				for (byte i = 0; i < tag_count; i++) {
					Tag tag = TagScanner.scanTag(rawData);
					if (tag == null)
						throw new CorruptedPacketException();
					tag_list.add(tag);
				}

				KadContact contact = routing_table.getContact(clientID);
				if (contact != null) {
					contact.setTCPPort(tcpPort);
					contact.setVersion(version);
				}
				// ignore message if contact is not in routing table
				/*
				 * ContactAddress address = new ContactAddress(new
				 * IPAddress(packet.getSender()),packet.getSender().getPort());
				 * KadContact add_contact = new KadContact(clientID, address,
				 * tcpPort,version, null);
				 * routing_table.addContact(add_contact);
				 * 
				 * add_contact.setConnected(true);
				 */

			} else if (packetOPCode == KADEMLIA2_REQ) {
				byte type = rawData.get();

				byte[] client_id_raw = new byte[16];
				rawData.get(client_id_raw);
				ClientID targetClientID = new ClientID(client_id_raw);

				client_id_raw = new byte[16];
				rawData.get(client_id_raw);
				ClientID receiverClientID = new ClientID(client_id_raw);
				RequestType requestType = RequestType.FIND_VALUE;
				switch (type) {
				case JKadConstants.FIND_VALUE:
					requestType = RequestType.FIND_VALUE;
					break;

				case JKadConstants.STORE:
					requestType = RequestType.STORE;
					break;

				case JKadConstants.FIND_NODE:
					requestType = RequestType.FIND_NODE;
					break;
				}

				lookup.processRequest(packet.getAddress(), requestType,
						targetClientID, receiverClientID, 2);
			} else if (packetOPCode == KADEMLIA2_RES) {
				byte[] client_id_raw = new byte[16];
				rawData.get(client_id_raw);
				int contactCount = byteToInt(rawData.get());
				List<KadContact> contact_list = new LinkedList<KadContact>();
				for (int i = 0; i < contactCount; i++) {
					contact_list.add(getContact(rawData));
				}
				lookup.processResponse(packet.getAddress(), new ClientID(
						client_id_raw), contact_list);
			} else if (packetOPCode == KADEMLIA2_PUBLISH_KEY_REQ) {
				byte[] client_id = new byte[16];
				rawData.get(client_id);
				ClientID clientID = new ClientID(client_id);
				int count = rawData.getShort();
				for (int i = 0; i < count; i++) {
					byte[] hash = new byte[16];
					rawData.get(hash);
					byte tagCount = rawData.get();
					TagList tag_list = new TagList();
					for (int j = 0; j < tagCount; j++) {
						Tag tag = TagScanner.scanTag(rawData);
						if (tag == null)
							throw new CorruptedPacketException();
						tag_list.addTag(tag);
					}
					Source source = new Source(clientID, tag_list);
					source.setAddress(new IPAddress(packet.getAddress()));
					source.setUDPPort(packet.getAddress().getPort());

					KadContact contact = routing_table.getContact(clientID);
					if (contact != null)
						source.setTCPPort(contact.getTCPPort());

					indexer.addKeywordSource(new Int128(hash), source);
				}
				KadPacket response = PacketFactory.getPublishRes2Packet(
						clientID, indexer.getKeywordLoad());
				_network_manager.sendKadPacket(response, sender_address,
						sender_port);

			} else if (packetOPCode == KADEMLIA2_PUBLISH_RES) {
				byte targetID[] = new byte[16];
				rawData.get(targetID);
				int load = byteToInt(rawData.get());
				publisher.processGenericResponse(new ClientID(targetID), load);
			} else if (packetOPCode == KADEMLIA2_PUBLISH_SOURCE_REQ) {
				byte[] client_id = new byte[16];
				byte[] source_id = new byte[16];

				rawData.get(client_id);
				rawData.get(source_id);

				int tagCount = rawData.get();
				TagList tag_list = new TagList();
				for (int i = 0; i < tagCount; i++) {
					Tag tag = TagScanner.scanTag(rawData);
					if (tag == null)
						throw new CorruptedPacketException();
					tag_list.addTag(tag);
				}
				Source source = new Source(new ClientID(client_id), tag_list);
				source.setAddress(new IPAddress(packet.getAddress()));
				source.setUDPPort(packet.getAddress().getPort());

				KadContact contact = routing_table.getContact(new ClientID(
						client_id));
				if (contact != null)
					source.setTCPPort(contact.getTCPPort());

				indexer.addFileSource(new Int128(source_id), source);

				KadPacket response = PacketFactory.getPublishRes2Packet(
						new ClientID(client_id), indexer.getFileSourcesLoad());

View Full Code Here

TOP

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

TOP