Giter Site home page Giter Site logo

oblac / jodd Goto Github PK

View Code? Open in Web Editor NEW
4.1K 263.0 724.0 41.82 MB

Jodd! Lightweight. Java. Zero dependencies. Use what you like.

Home Page: https://jodd.org

License: BSD 2-Clause "Simplified" License

Shell 0.02% Java 98.11% Python 1.73% HTML 0.14%
java jodd micro-framework ioc aop database http-client html-parser jquery mail

jodd's People

Contributors

benbenw avatar brandon8863 avatar cproof avatar cyburs avatar flowbehappy avatar fuwjax avatar hengyoush avatar iamzhangxin-0412 avatar igr avatar jdstroy avatar jgangemi avatar jhult avatar karolbedkowski avatar mfarid avatar moh-sushi avatar mushketyk avatar neroux avatar oddcb avatar pascalschumacher avatar pvdissel avatar rhowe avatar sannysoft avatar slandelle avatar smarg120 avatar tinobino avatar wenerme avatar wjw465150 avatar xaph avatar xilnick avatar xun404 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jodd's Issues

About FileUtil.doMoveFile method

Hi,
I found that all move* methods in jodd.io.FileUtil calls doMoveFile method, and use file.renameTo method, but this method has some problem.

this method is not work(will be return false) on different file system on unix and linux, also not work between different drive on Windows, for example: rename a file from C: to D:

you can try it youself~~

AutomagicMadvocConfigurator findpath problem

Please make AutomagicMadvocConfigurator findpath configable.

There is a third jar A,another third jar B, A partly depend on B and my project depend A.
Unfortunately,there is a class named "XXXResult" which extend a class in B ,I don't need "XXXResult" and didn't include B , however , AutomagicMadvocConfigurator fund "XXXResult" and try to load this class and throwed MadvocException.

real code of "XXXResult" like:
public class MyResult extends org.apache.struts2.dispatcher.StrutsResultSupport {
//....
}

ReflectUtil.getFieldConcreteType Problems

As the testcases:

public static class BaseClass<A, B> {

    public A f1;
    public B f2;
    public String f3;
    public A[] array1;
}

public static class BaseClass2<A> extends BaseClass<A, Integer> {
}

public static class ConcreteClass2 extends BaseClass2<String> {
}

@Test
public void testGetFieldConcreteType() throws Exception {
    Field array1 = BaseClass.class.getField("array1");
    Field f2 = ConcreteClass2.class.getField("f2");

    //expected:<class [Ljava.lang.String;> but was:<class [Ljava.lang.Object;>
    assertEquals(String[].class, ReflectUtil.getFieldConcreteType(array1, ConcreteClass2.class));

    //expected:<class java.lang.Integer> but was:<null>
    assertEquals(Integer.class, ReflectUtil.getFieldConcreteType(f2, ConcreteClass2.class));

    //PASS
    assertEquals(Integer.class, ReflectUtil.getFieldConcreteType(f2, BaseClass2.class));
}

Two problems on `WildcardPathMacros`

Version: 3.4.5-SNAPSHOT

1 . match problem

two path with extension = "do"
/${entityName}/dba.delete & /${entityName}/dba.delete_multi
but /config/dba.delete_multi.do match to delete, not delete_multi

2 . extract problem

path /${entityName}/dba.modify/${type}/${name} with extension = "do"
url /config/dba.modify/bool/isLeaf.do

but name is "isLeaf.do" with extension ".do", not "isLeaf"

No support for short or byte types in the jodd.format.PrintfFormat class

I don't see any short or byte types for jodd-core's jodd.format.PrintfFormat class.

I am looking to convert some code from another printf implementation to jodd-core; the other implementation supports byte and short, but jodd does not (it is implicitly cast into an integer and formatted as such).

jodd.http: HttpRequest & HttpResponse body encode problem

jodd version:3.4.2
I read the source code and figure out HttpRequest & HttpResponse use “StringPool.ISO_8859_1” to encode the body, and I have to transcode it by myself like:

new String(response.body().getBytes(StringPool.ISO_8859_1), StringPool.UTF_8);

However, charset can be find in http head "Content-Type" sometime.

FindFile includes, imply "AND" rule for all include-patterns

Stumble upon this method:

    protected boolean acceptFile(File file) {
            String matchingFilePath = getMatchingFilePath(file);

            if (includes != null) {
                    for (String pattern : includes) {
                            if (match(matchingFilePath, pattern) == false) {
                                    return false;
                            }
                    }
            }
   .........

That means if we set includes property to "x.txt", "y.txt", then it must match one file that has both name "x.txt" and "y.txt".
Would it be more natural if it match either "x.txt" or "y.txt".
So the code will be like :

                    for (String pattern : includes) {
                            if (match(matchingFilePath, pattern) == true) {
                                    return true;
                            }
                    }

Proxetta ASM Upgrade

First of all thanks to great library Proxetta, its clean well documented and works well.

As i understood proxetta has dependency to ASM 3.3

Is it possible to upgrade ASM to 4.0
ASM 4.0 supports Java 7 and invokedynamic
I am not sure but api change might be required.

Thanks

Here is 3.3 to 4.0 changes for ASM
http://asm.ow2.org/jdiff33to40/changes.html

Negative Content-Length, on Chunked Transfer Encoding causing Buffer Exception

Jodd ver 3.4.7.
In HttpBase.readBody, allow negative allocation of FastCharArrayWriter.
Some service will return header, with negative Content-Length, when Chunked Transfer Encoding.

Proposed fix:

int len = Integer.parseInt(contentLen);
if (len>0) {
  FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter(len);
     ...
}

How about api `SocketProvider` for `http`?

  1. we can set default settings just one time, like soTimeout.
  2. for HttpBrowser, we can choose a SocketPoolProvider, keep alive of course.

or this have been achieved, or inaccessible?

jodd.jerry.Jerry class problem

My use case:

public boolean onNode(Node node, int position) {
        System.out.println(position + "\n\n" + node.getInnerHtml());
        for (int i = 0; i < node.getChildNodesCount(); i++)
            System.out.println(i + " " + node.getChild(i).getHtml());
        return false;
    }

when i do like this:

doc.find("div.trackTraceResultContainer").find("tbody").each(this);

i'm getting result:

0

    <tr class="odd">        <td class="first">2013-02-26 22:06:28</td>      <td>przesyłka odebrana od klienta<br>(<i>przesyłka nadana w paczkomacie</i>)</td>     <td></td>   </tr>   <tr class="even">       <td class="first">2013-02-27 05:25:03</td>      <td>przesyłka w sortowni<br>(<i>przesyłka w drodze</i>)</td>      <td></td>   </tr>   <tr class="odd">        <td class="first">2013-02-28 17:20:03</td>      <td>przesyłka gotowa do odbioru własnego w terminalu/oddziale<br>(<i>oczekuje na odbiór</i>)</td>        <td></td>   </tr>   
0   
1 <tr class="odd">      <td class="first">2013-02-26 22:06:28</td>      <td>przesyłka odebrana od klienta<br>(<i>przesyłka nadana w paczkomacie</i>)</td>     <td></td>   </tr>
2   
3 <tr class="even">     <td class="first">2013-02-27 05:25:03</td>      <td>przesyłka w sortowni<br>(<i>przesyłka w drodze</i>)</td>      <td></td>   </tr>
4   
5 <tr class="odd">      <td class="first">2013-02-28 17:20:03</td>      <td>przesyłka gotowa do odbioru własnego w terminalu/oddziale<br>(<i>oczekuje na odbiór</i>)</td>        <td></td>   </tr>
6 

we can see 3 tr tags.
But, when i want to find them:

doc.find("div.trackTraceResultContainer").find("tbody").find("tr").each(this);

as result i'm getting only one, onNode is called only for first tr:

0

        <td class="first">2013-02-26 22:06:28</td>      <td>przesyłka odebrana od klienta<br>(<i>przesyłka nadana w paczkomacie</i>)</td>     <td></td>   
0       
1 <td class="first">2013-02-26 22:06:28</td>
2       
3 <td>przesyłka odebrana od klienta<br>(<i>przesyłka nadana w paczkomacie</i>)</td>
4       
5 <td></td>
6   

URL: http://sendit.pl/track-trace/603717057344200029906292

PRE tag not considered as a special tag

Hi,

I have some html code that contains code blocks within <pre> tags, such as:

<pre>
  new Foo<Bar>() {}
</pre>

Lagarto complains that the <bar> tag is not properly closed, even when setting parseSpecialTagsAsCdata to true.

IMHO, parseSpecialTagsAsCdata should handle this tag.

Moreover, shouldn't parseSpecialTagsAsCdata default to true?

Thanks a lot for this great library, it rocks!
Regards,

Stéphane

jodd mobile version can not find class named "jodd.JoddCore"

when i used jodd-mobile-2.4.1.jar in android,there was exception "can not find class named 'jodd.JoddCore'".

jodd.io.StreamUtil imports "jodd.JoddCore" class.but there is no it in the jar.

i think that jodd-mobile-2.4.1.jar should have no dependencies.

thank you!

Lower LagartoDOMBuilderTagVisitor log level

Hi,

This might seem weird, but could it be possible to lower LagartoDOMBuilderTagVisitor logging level from warn to info?

We use Lagarto to parse whole websites, and logs are literally flooded when warn level is enabled. Malformed HTML is sadly the norm on the internet, so IMHO, Lagarto should treat those events as informative.

WDYT?

jodd-email:Message parsing failed by attachment name is null

Sorry, but also trouble you friend.
When i received email...

jodd.mail.MailException: Message parsing failed; <--- java.lang.NullPointerException
    at jodd.mail.ReceivedEmail.<init>(ReceivedEmail.java:43)
    at jodd.mail.ReceiveMailSession.receive(ReceiveMailSession.java:256)
    at jodd.mail.ReceiveMailSession.receiveEmail(ReceiveMailSession.java:182)


---[cause]------------------------------------------------------------------------
java.lang.NullPointerException
    at javax.mail.internet.MimeUtility.decodeText(MimeUtility.java:573)
    at jodd.mail.EmailAttachment.<init>(EmailAttachment.java:32)
    at jodd.mail.att.ByteArrayAttachment.<init>(ByteArrayAttachment.java:19)
    at jodd.mail.ReceivedEmail.addAttachment(ReceivedEmail.java:257)
    at jodd.mail.ReceivedEmail.processPart(ReceivedEmail.java:147)
    at jodd.mail.ReceivedEmail.processPart(ReceivedEmail.java:135)
    at jodd.mail.ReceivedEmail.parseMessage(ReceivedEmail.java:88)

I found the method 'addAttachment'
see https://github.com/oblac/jodd/blob/master/jodd-mail/src/main/java/jodd/mail/ReceivedEmail.java#L118
some times the Part don't have file name ,file name is null.

so:

    protected EmailAttachment(String name, String contentId) {
        try {
            this.name = MimeUtility.decodeText(name);
        } catch (UnsupportedEncodingException ueex) {
            throw new MailException(ueex);
        }
        this.contentId = contentId;
    }

MimeUtility.decodeText(null)

The same problem to get the email from in ReceiveEmail.parseMessage,some times email have no from. msg.getFrom()[0].toString() while throws NPE...

protected void parseMessage(Message msg) throws MessagingException,
            IOException {
        // flags
        setFlags(msg.getFlags());

        // msg no
        setMessageNumber(msg.getMessageNumber());

        // standard stuff
        setFrom(msg.getFrom()[0].toString());

I think the most important problem is that when I receive mail, I can not participate in the process, once an e-mail reception failed, I need to start all over again. If we receive mail in the process can add some custom processing monitor? Or implementation. Or I could just received from the server a local store one, do not wait to receive the memory after they have finished and then stored locally.

translated by google ..sorry..

Will @In support generic?

GenericAction<E, T>

@In
protected E id;
@In
protected E[] ids;
@In(value = "$_this")
protected T entity;

now ScopeData.In.type make not different what inject into the action

CSSellyException: Invalid combinator on :contains with Parentheses

Whenever I try to execute a CSS selector which has a :contains extension in which there is a '(' or ')' character, I get the exception:
CSSellyException: Invalid combinator <'>. (state: 6)

An example of this error can be seen in trying to select a paragraph element which contains the text "401(k)" by calling: jerry.$("p:contains('401(k)')")

I've created a junit test in which I tried escaping the parentheses, and using different style quotation marks (" or '), but I always get the invalid combinator error:
jodd.csselly.CSSellyException: Invalid combinator <'>. (state: 6)
at jodd.csselly.CSSellyLexer.yylex(CSSellyLexer.java:892)
at jodd.csselly.CSSelly.parse(CSSelly.java:37)
at jodd.lagarto.dom.NodeSelector.select(NodeSelector.java:38)
at jodd.jerry.Jerry.find(Jerry.java:277)
at jodd.jerry.Jerry.$(Jerry.java:288)

Attachment name Issue

I am using jodd-3.4.2 to send email. The attachment name is in Chinese. The email was successfully sent out with attachment, but the name of attachment shown in the email displayed wrong.
Following is the code how attachment attached.

.attach(EmailAttachment.attachment().file('c:\\temp\\中文.csv'))

But in the email, the attachment name was changed from '中文.csv' to '-�.csv'

My environment

  • jodd-3.4.2
  • Windows 7 64-bit edition with java version "1.6.0_33"
  • Java HotSpot(TM) 64-Bit Server VM.
  • System.getProperty("file.encoding") --> GBK

jodd works not well with tomcat & mysql

ThreadDbSessionProvider is jodd's default SessionProvider. tomcat will work with a thread pool.when tomcat creates one thread.the thread will stay in the pool and never release the Dbsession.

there is a variable named 'wait_time' in mysql.when one connection never use for a long time,the mysql server will close it.

so,when the system never query the db for a long time.the db server closes the connection.when a query comes,one thread of tomcat in thread pool will run.it holds one Dbsession and use the Dbsession to query the db,and throw "connection is close" exception.

maybe,you say that i can use CoreConnectionPool with validateConnection=true.but in tomcat,the connection will be hold by one thread in the tomcat thread pool,and never be returned to CoreConnectionPool ,and never be checked that it is a validate connection.

thanks.

Can I set global default charset with received content, body() method?

Hi, I have some questions about default charset with received content,body() method in Jodd.Http. It's always returns the raw string
(always encoded as ISO-8859-1 even though you had set the default charset to UTF-8 for queryEncoding,formEncoding and so on...).

    For example, my code as below:


package com.util.http;


import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import jodd.JoddHttp;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;
import jodd.util.StringPool;
import jodd.util.StringUtil;

public class HttpKit {
    public static void main(String[] args) {
        HttpResponse response =HttpRequest.get("http://www.baidu.com/s")
                .formEncoding("UTF-8")
                .queryEncoding("UTF-8")
                .query("word", "ip").charset("UTF-8").send();
        //way1 ---> messy code
        System.out.println(response);
        //way2 ---> messy code
        System.out.println(response.bodyText(response.bodyText(),"text/html","UTF-8"));
        //way3 ---> ok ,it;s work well but I have to convert every time,it's really very inconvenient
        System.out.println(StringUtil.convertCharset(response.toString(), StringPool.ISO_8859_1, StringPool.UTF_8));
    }
}

By the test, it's prove even I have already set the Charset to UTF-8 but still mess code,like following image:

   Way 1 and Way 2 both are mess code, you have to convert it every time,because the charset had been hard-coded in jodd.http.HttpBase ,above

line 379~411 as following,


/**
     * Returns <b>raw</b> body as received or set (always in ISO-8859-1 encoding).
     * If body content is a text, use {@link #bodyText()} to get it converted.
     */
    public String body() {
        return body;
    }

    /**
     * Returns <b>raw</b> body bytes.
     */
    public byte[] bodyBytes() {
        if (body == null) {
            return null;
        }
        try {
            return body.getBytes(StringPool.ISO_8859_1);
        } catch (UnsupportedEncodingException ignore) {
            return null;
        }
    }

    /**
     * Returns {@link #body() body content} as text. If {@link #charset() charset parameter}
     * of "Content-Type" header is defined, body string charset is converted, otherwise
     * the same raw body content is returned.
     */
    public String bodyText() {
        if (charset != null) {
            return StringUtil.convertCharset(body, StringPool.ISO_8859_1, charset);
        }
        return body();
    }

Yes, as you see it's said
    body as received or set (always in ISO-8859-1 encoding).

    you can not set the default charset encoding such as UTF-8 and you have to manually convert all the time use code like

           StringUtil.convertCharset(body, StringPool.ISO_8859_1, charset);

          Really very inconvenient,it can be possible provider a method for set the default charset encoding with received or set body?

ObjectUtil.writeObject method is not flush buffer

ObjectUtil.writeObject method is not flush buffer,
In My Project,i used ObjectUtil.writeObject,I found it will lost data!
Have Bug code is:

/**
* Writes serializable object to a file. Existing file will be overwritten.
/
public static void writeObject(File dest, Object object) throws IOException {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(dest);
oos = new ObjectOutputStream(new BufferedOutputStream(fos));
oos.writeObject(object);
} finally {
StreamUtil.close(fos);
StreamUtil.close(oos);
}
}
it shoud:
/
*
* Writes serializable object to a file. Existing file will be overwritten.
*/
public static void writeObject(File dest, Object object) throws IOException {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
BufferedOutputStream bos = null;
try {
fos = new FileOutputStream(dest);
bos = new BufferedOutputStream(fos);
oos = new ObjectOutputStream(bos);
oos.writeObject(object);
} finally {
StreamUtil.close(bos);
StreamUtil.close(fos);
StreamUtil.close(oos);
}
}

URLDecoder omitting "+"

In some (old?) implementation, the query value will contain "+", represent [space] character.
URLDecoder does not take care of "+" conversion to space.

URLDecoder is being used by HttpUtil.parseQuery, so its result (name and value) may contain "+", which shall be converted to space.

Proposed:

    public static String decode(String source, String encoding) {
      ...
      for (int i = 0; i < length; i++) {
        int ch = source.charAt(i);
          if (ch == '%') {
            ...
          } else if (ch == '+') {  // check if has +
             bos.write(' ');  // convert to space
          } ...

Does jodd jerry support namespace scoping?

I want to search some elements from the XML document which have namespace scope like bellows:

<cfg:test>
    <cfg:node>This is a text</cfg:node>
</cfg:test>

But, I get an exception as bellows:

jodd.csselly.CSSellyException: Unsupported pseudo class: test

Does jodd jerry support namespace scoping?

Hey,TextResult has a big trouble!

Jodd 3.4.3

My code is like:
return "text:this text contents chinese chars 中文 ";
and i got
this text contents chinese chars ??

i have set all environments (os, jvm,netbeans,tomcat,maven) 's characterEncoding toUTF-8

it may caused by jodd.madvoc.MadvocResponseWrapper.setContentType(), this method will erase responseWrapper.characterEncoding.

waitting for reply ;)

Make Jerry implement Iterable

For those of us using Groovy it would be really great if Jerry could implement java.lang.Iterable<Jerry>. This would mean Groovy's standard iterator functions (e.g. each, collect, etc.) would be able to iterate over the nodes contained in the Jerry object.

For example I could pull a List of all the field names out of a form by doing this:

jerry.find(':input')*.attr('name')

Can't import into intellij

When I run "gradlew cleanIdea idea", the result is:

FAILURE: Could not determine which tasks to execute.
What went wrong:
Task 'cleanIdea' not found in root project 'jodd-master'.

What should I do?

About "CachingPageInterceptor"

First of all, it is an ActionInterceptor, of course.

Base on net.sf.ehcache.

it can be used like this

[xxx.xxx.cache.CachingPageInterceptor]
#Ehcache name
cacheName=Caching_20min
[xx.xxx.interceptor.PostInterceptorStack]
xxx.xx.interceptor.PostHitsInterceptor,xxx.xxx.cache.CachingPageInterceptor,jodd.madvoc.interceptor.ServletConfigInterceptor

it works just like AuthInterceptor, if hit cache, load response form cache, else do

buildPage(actionResult){
...;
Object resultValueObject = actionRequest.invoke();
madvocController.render(actionRequest, resultValueObject);
...
}

another ServletResponseWrapper base on ByteBuffer is need to get response.body

【More >>】

As post need count hits, PostHitsInterceptor is to plus post's hits and save it to database, so it is ahead of CachingPageInterceptor

[Props] How about `classname.@extends`

for example:

[common]
encoding=UTF-8

[loader]
bar=BAR
foo=FOO

[engine]
resourceLoaderClass=webit.script.loaders.impl.ClasspathLoader

[webit.script.Engine]
@extends=common, engine

[webit.script.loaders.impl.ClasspathLoader]
@extends=common, loader

for petite or props,
Poor in expression, hope you have got it :))

Please implement filter() in Jerry

I started using Jerry and found out that it implements not() but doesn't implement filter(). It would be cool if it did as it's sometimes pretty handy to be able to narrow down the set of previously selected elements.

some error on the website

Hello, jodder, i'm a fan of jodd.
I'd like to report that http://joddframework.org/ website have something wrong.
"Packed in only 1 Mb. Super easy to use."
I see this, but when I gonna download it, I see a 2.5MB zip file, the jodd-3.4.10.jar is larger than that.
maybe this is no big deal, just report it to you.
Jodd is my best favoriate, wish jodd better and better.

How about use ASM to speed BeanUtil

for public class public field or with public getter/setter.

In my mind, we can generate one ASM resolver for one class
(not one for one property).
property has a index, we get/set value by index, and the index keeps in it's upstair.
resolver will not do convert works, it's the upstair's duty.

resolver's code may like

public Object get(Object bean, int index){
    switch(index){
        case 0:
            return ((User)bean).getName(); //getter
        case 1:
            return ((User)bean).address; //public field
        ....
        default:
            //Exception ?
    }
}

public Object set(Object bean, int index, Object value){
...
}

Jodd.db:one-to-many relations problem

version:3.4.3
Mysql jdbc: 5.1.21

i have tried the new features,i just want to say awesome!
however, i have some problems.

  1. when i use query.find() to fetch one result "one-to-many relations" same not deal all records , telecomms.prefixes.length ==1 or null.
  2. how if don't put the same result into result's list, when use "one-to-many relations" ,i have to remove duplicate result(s) by myself.

Props enhancement: support "+="

How about this:

foo=one
foo=two
foo+=three

when appendDuplicateProps == false

foo will be two,three

and when appendDuplicateProps == true

foo keep one,two,three

Some problems about directaccess

  • classCounter should be thread safe;
  • when field/method/class is not public, we should use default accessorFactory,
    when field is final, it can't be reset, the set method should like:
    public void set(Object target, Object value) {
          throw new BeanUtilException("can't reset a final Field: User#name");
    }

jodd.lagarto.dom.Node class problem

Hello.
I found strange behavior in Node class.
I have onNode callback function, and inside code like this:

public boolean onNode(Node node, int position) {
        System.out.println(node.getInnerHtml());
        for (int i = 0; i < node.getChildElementsCount(); i++)
            System.out.println(i + " " + node.getChild(i).getHtml());
        return false;
    }

First sysout is printing code like this:

            <td nowrap>Terminal&nbsp;podjęcia:</td>            <td class="data">RZESZÓW / RUDNA MAŁA</td>            <td nowrap>Terminal&nbsp;dostawy:</td>          <td class="data">TRZEBNICA</td>     

So we have 4 childes, but sysout inside loop is printing:

0           
1 <td nowrap>Terminal&nbsp;podjęcia:</td>
2           
3 <td class="data">RZESZÓW / RUDNA MAŁA</td>

BeanUtilUtil need a better API

since direct access has been rolled back,
but JoddBean.introspector may also needed for some reason.
rewrite or hide some property, etc.
so BeanUtilUtil should not care about invoke a setter/getter method or use field.get()/field.set()
In my mind, PropertyDescriptor is better than divide to MethodDescriptor and FieldDescriptor.

NoClassDefFoundError in AutomagicMadvocConfigurator will break down madvoc

For example, my project has a support named webit.script.support.struts.WebitScriptResult for struts2

AutomagicMadvocConfigurator will find and try to load it,
unfortunately, it throws an error

java.lang.NoClassDefFoundError: org/apache/struts2/dispatcher/StrutsResultSupport
at java.lang.ClassLoader.defineClass1(Native Method)
....

now we can avoid this problem:

[automagicMadvocConfigurator]
includedEntries=webit.script.support.jodd.madvoc.*,jodd.*

however, this will be simpler and better if there has a flag to ignore NoClassDefFoundError or not.

jodd email-Message parsing failed

jodd 3.4.7.

I received an e-mail that contains an attachment, the receiver when an exception is thrown

jodd.mail.MailException: Message parsing failed; <--- java.lang.NullPointerException
---[cause]------------------------------------------------------------------------
java.lang.NullPointerException
    at java.lang.String.getBytes(String.java:945)
    at jodd.mail.ReceivedEmail.processPart(ReceivedEmail.java:93)
    at jodd.mail.ReceivedEmail.processPart(ReceivedEmail.java:106)
    at jodd.mail.ReceivedEmail.parseMessage(ReceivedEmail.java:72)

By debug I have found is caused because of this method

EmailUtil.extractEncoding(contentType);

When I use this method processPart received an e-mail with attachments
debug info:
the attachment ContentType is
text/html;
name="2013_10_02_Global_Webcast_2013__Brand_Insights_with_Catalyst.htm"

then use method

EmailUtil.extractEncoding(contentType);

The return value is null

email.addAttachment(fileName, mimeType, contentId, stringContent.getBytes(encoding));

getBytes(null) ....

see :https://github.com/oblac/jodd/blob/master/jodd-mail/src/main/java/jodd/mail/ReceivedEmail.java#L93

fix:
if the encoding is null ,use default ? like UTF-8? or the system charset?

Jerry: OutOfBoundsException occurs while trying to load an html body

Hi,

With some URLs, Jerry.jerry(bodyContent) throws an OutOfBoundsException.

My code is very simple :

File file = new File(SystemUtil.getTempDir(), "body.html");
         NetUtil.downloadFile(baseUrl, file);
         jerry = Jerry.jerry(FileUtil.readString(file));

Example of URL failing : http://www.kelkoo.fr/c-134601-barbecue-plancha-et-accessoires.html

I've tried to verify /tmp/body.html file and to open it with my browser, it's working good.
I guess the DOM contains some errors, but should not Jerry be robust enough to be able to load the page anyway?

Full stack trace :

java.lang.IndexOutOfBoundsException: null
    at java.nio.StringCharBuffer.subSequence(StringCharBuffer.java:116) ~[na:1.6.0_24]
    at jodd.lagarto.LagartoParserEngine.parseSpecialTag(LagartoParserEngine.java:664) ~[jodd-lagarto-3.4.8.jar:3.4.8]
    at jodd.lagarto.LagartoParserEngine.parseTagAndAttributes(LagartoParserEngine.java:560) ~[jodd-lagarto-3.4.8.jar:3.4.8]
    at jodd.lagarto.LagartoParserEngine.parseTag(LagartoParserEngine.java:436) ~[jodd-lagarto-3.4.8.jar:3.4.8]
    at jodd.lagarto.LagartoParserEngine.parse(LagartoParserEngine.java:163) ~[jodd-lagarto-3.4.8.jar:3.4.8]
    at jodd.lagarto.LagartoParserEngine.parse(LagartoParserEngine.java:117) ~[jodd-lagarto-3.4.8.jar:3.4.8]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.