DSL « Development « Java Tutorial / Blog

Home
Java Tutorial / Blog
1.Algorithm
2.Apache
3.Applet
4.Database
5.Date
6.Design Pattern
7.Development
8.Dump
9.Eclipse
10.EJB
11.Excel
12.File IO
13.Generic
14.GlassFish
15.Google App Engine
16.Graphics
17.GWT
18.IntelliJ
19.Internationlization
20.iText
21.JavaFX
22.JAXB
23.JBoss
24.JDBC
25.JDK
26.JEE
27.Jetty
28.JMS
29.JSP
30.JSR
31.JUnit
32.JVM
33.Linux
34.Log4j
35.Maven
36.Memcached
37.Memory
38.MSAccess
39.MySQL
40.NetBeans
41.Network
42.Oracle
43.OSGi
44.OsX
45.Password
46.Photo
47.phpMyAdmin
48.PivotTable
49.Quartz
50.Query
51.Replication
52.Security
53.Select
54.Servlet
55.Session
56.Struts
57.Swing
58.Thread
59.Tomcat
60.Update
61.WebService
62.Website
63.Wicket
64.Windows
65.Word
66.XML
Java Tutorial / Blog » Development » DSL 

1. Java static imports + Fluent interfaces + Builder pattern= DSL    blog.centuryminds.com

So, let's start with static import , a nice Java feature introduced in its 5th version. Until Java 5, we could only import classes for using in our code, so that, instead of using something as ugly as java.util.List list= new java.util.ArrayList() we could simplify by importing the List and ArrayList classes and omit the package class in the creation and usage of the objects.

But, what happens when we want to use static methods or properties of other classes?

MyFunnyClass.myMoreFunnierMethod(param)... 

2. Create your own Java Code Generator with DSL in 15 minutes [part 3]    reboltutorial.com

Are you fed up with launching your heavy-weighted java eclipse IDE when you just need to create a quick java class to do some testing (by the way if someone knows an equivalent of Snippet Compiler but for Java that would interest me) ? Don't you miss your simple notepad just because it would need a little twist ? Or maybe you're just learning Java with an amazing editor like BlueJ which still lacks code generation. Using this lighweight text DSL or Domain Specific Language is a solution which wi...

3. A DSL for collections in Java    code.joejag.com

When writing Java code I often find it laborious to create collections using the java.util.* collection classes. To avoid this, I've been using a mini-DSL to reduce my collections code.

import static com.joejag.common.collections.Dsl.*;

// A list
List list = list("abc", "def");

// A set
Set set = set("Sleepy", "Sneezy", "Dozy");

// A Map
Map map = map(entry("Joe", 28), entry("Gerry", 39)); 

Here is the underlying code.

package com.joejag.common.collections;

import java.util.*;

public class ... 

4. Create your own DSL for Java or C# (part 4): adding a Semantic Layer    reboltutorial.com

In the context of a DSL, a semantic model is an in-memory representation, usually an object model, of the same subject that the DSL describes. The Semantic Model increases the flexibility in parsing and also in execution. You can execute the Semantic Model directly or you can use code generation. If you're using code generation you can base that code generation off the Semantic Model which completely decouples it from parsing.

In this lesson, after parsing the user submission through the DSL pars...

5. XMLTool Java DSL for create XML    toolbox.byexamples.com

In Java, we usually create XML document through DOM API that come with standard JDK.

DOM API is good, but sometime the code we wrote with DOM API is verbose. Here is an example of the code required to generate a simple 8 lines XML . Yes, 13 line of Java code to generate a 8 lines XML.

Other options are using JDOM or dom4j that simplify DOM manipulation in Java.

If you just want a simple fluent API for create simple XML, XMLTool is another good option.

The sample code below quote from XMLTool Manual w...

6. ElSql, a new external SQL DSL for Java    blog.jooq.org

Stephen Colebourne who is frequently commenting on the lambda-dev and other Java 8 mailing lists, has recently published an idea he has been having for a while: ElSql, a new external SQL DSL for Java.

An example SQL statement is given on the blog posts or on GitHub :

@NAME(SelectBlogs)
   @PAGING(:paging_offset,:paging_fetch)
     SELECT @INCLUDE(CommonFields)
     FROM blogs
     WHERE id = :id
       @AND(:date)
         date > :date
       @AND(:active)
         active = :active
 ... 

7. An embedded Java DSL for manipulating hierarchical JavaBeans    dow.ngra.de

Just yesterday I was thinking on how to improve the DSLs I'm working on at the moment and got an idea, which wasn't too useful in the context of SQL, but could be used for something else.

Imagine we have three JavaBeans (I'm omitting getters/setters for readability): [java] class Company { String name; Address address; Collection employees; }

class Address { String country; String zip; String town; String street; }

class Employee { String firstName; String lastName; Address addr...

8. Pragmatic DSL in Practice, with Java and Drools    blog.codecentric.de

When I listened to Martin Fowlers Talk last week at Java User Group Cologne, I felt the urge to talk about one of my projects at codecentric. Martin said that DSLs are very useful because the business people can actually read the code programmers produce. This is in fact more powerful than the often brought argument, that business people can write code. Martin did a fair amount of ranting on the structure of Java code. He said that you need to decode it like a detective, so he built his own lang...

9. Awaitility Java DSL for easy testing of asynchronous systems    jayway.com

Testing asynchronous systems is hard. Not only does it require handling threads, timeouts and concurrency issues, but the intent of the test code can be obscured by all these details. Awaility is a DSL that allows you to express expectations of a asynchronous system in a concise and easy to read manner.

So let's assume that we send an "add user" message to our asynchronous system like this:

  1. publish ( new AddUserMessage ( "John Doe" ) ) ;

In your test case Awaitility can help you to easily verify that the ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.