الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الحزمة StringTemplate

بدأه العيافـي في 4 فبراير 2011 · 2 رد · 820 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

و انا ابحث عن شي معين في الانترنت وجدت الحزمة stringtemplate.jar

وضيفتها تحويل ( قالب ) الى نص يمكنك استخدامه في برنامجك.

مثال لتوضيح الفكره ( هذا المثال من الامثله الموجوده في الحزمه )

StringTemplate query = new StringTemplate(
				"UPDATE customers SET customerName='$customer$'," +
				" customerAddress='$address$' WHERE id=$id$");

		query.setAttribute("customer", "Frank");
		query.setAttribute("address", "1313 Mocking Bird Lane");
		query.setAttribute("id", "4453");



System.out.println(query); 
		// OUTPUT: 
		//UPDATE customers SET customerName='Frank', customerAddress='1313 Mocking Bird Lane' WHERE id=4453

لا حض في المثال السابق اني قمت باضافة $$ للعناصر المتغيره

و الامر التالي لاسناد القيمة

query.setAttribute("customer", "Frank");

نقطه اخرى : بامكانك انشاء ملف كــ ( قالب ) وليس نص.

روابط الحزمة:

http://www.stringtemplate.org/

http://www.antlr.org/wiki/display/ST/Five+minute+Introduction

تم تعديل هذه المشاركة بواسطة العيافـي في 4 فبراير 2011 في 09:50

4
#2

تسلم أخي العيافي

لا حرمنا من جديدك الرائع .

تحية عطرة

عفواً أحبتي انقطاعي بسبب الدراسة دعواتكم بالتوفيق..

{ لا ينال العلم مستحٍ ولا مستكبر }

#3

وعليكم السلام ورحمه الله وبركاته

جزاك الله اخي العيافي .. ولكن بالنسبه لل SQL فاري انها ليست مجديه اري ان PreparedStatement افضل لعدم تعرضها ل sql injection

ولكن اري ان لها مميزات كثيره

اقتباس

What does StringTemplate do?

Structured text generation. StringTemplate supports the generation of structured text output such as web pages, source code, emails and newsletters from arbitary data structures without sacrificing model-view separation.

StringTemplate is non-intrusive and doesn't require your data structures to implement any specific contracts. It is designed to be embedded inside other applications and is distributed as a small library with no external dependencies except ANTLR (used for parsing the StringTemplate template language) and, the standard platform libraries (e.g. JDK 1.2 for the Java version).

Why should I use StringTemplate?

To ensure the separation of the specification of business logic and computation required to generate structured text from the specification of how that text is presented (i.e. it's formatting).

For web developers, this translates to ensuring that a web page's business and persistence logic is separated from the the page's presentation.

For developers involved in code generation, this translates to ensuring generation and persistence logic is separated from output code structure. This separation directly supports the development of retargetable code generators.

Other benefits of model-view separation:

1. Encourages the development of templates that are reusable in similar applications

2. Unentangled templates serves as clear documentation of the generated code structure

3. The templates (and hence the output or view) can be changed independently. Using more than one set of such templates is the basic mechanism for retargetable code generation

1
2coscqr.jpg

مواضيع مشابهة