DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Elevate your data management. Join a lively chat to learn how streaming data can improve real-time decision-making, and how to reduce costs.

Platform Engineering: Enhance the developer experience, establish secure environments, automate self-service tools, and streamline workflows

Build Cloud resilience. High-profiled cloud failures have shown us one thing – traditional approaches aren't enough. Join the discussion.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Avatar

Rafael Naufal

Software Developer at Atech

Sao Paulo, BR

Joined Jun 2008

Stats

Reputation: 21
Pageviews: 60.6K
Articles: 1
Comments: 8
  • Articles
  • Comments

Articles

article thumbnail
Applying Python To Modify Java Code
Python script intended to open each Java's project file, add the license term on the start of the file as a Java comment and writing it to the disk. 1) You'll need a Python interpreter. Check this out in http://python.org. 2) You'll need to enter the root file directory of the Java project, like python AddLicense.py ${path} where ${path} defines user project root directory. 3) See http://fcmanager.wiki.sourceforge.net 1:# Python script to add the LGPL notices to each java file of the FileContentManager project. 2:import os, glob, sys 3:License = """\ 4:/** 5:*FileContentManager is a Java based file manager desktop application, 6:*it can show, edit and manipulate the content of the files archived inside a zip. 7:* 8:*Copyright (C) 2008 9:* 10:*Created by Camila Sanchez [http://mimix.wordpress.com/], Rafael Naufal [http://rnaufal.livejournal.com] 11:and Rodrigo [rdomartins@gmail.com] 12:* 13:*FileContentManager is free software; you can redistribute it and/or 14:*modify it under the terms of the GNU Lesser General Public 15:*License as published by the Free Software Foundation; either 16:*version 2.1 of the License, or (at your option) any later version. 17:* 18:*This library is distributed in the hope that it will be useful, 19:*but WITHOUT ANY WARRANTY; without even the implied warranty of 20:*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21:*Lesser General Public License for more details. 22:* 23:*You should have received a copy of the GNU Lesser General Public 24:*License along with FileContentManager; if not, write to the Free Software 25:*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ 26: 27:size = len(sys.argv) 28:if size == 1 or size > 2: 29: print "Usage: AddLicense.py $1" 30: sys.exit(1) 31:inputPath = sys.argv[1] 32:if not os.path.exists(inputPath): 33: print inputPath, "does not exist on disk" 34: sys.exit(1) 35:if not os.path.isdir(inputPath): 36: print inputPath, "isn't a dir" 37: sys.exit(1) 38:for path, dirs, files in os.walk(inputPath): 39: fileWithLicense = '' 40: for filepath in [ os.path.join(path, f) 41: for f in files if f.endswith(".java")]: 42: content = file(filepath).read() 43: f = file(filepath, "w") 44: print >>f, License + "\n" + content 45: f.close() 46: 47:
March 17, 2008
· 2,440 Views

Comments

A rule for everybody who’s thinking about styling a button

Sep 03, 2013 · Mr B Loid

Here is my Ruby solution: http://rafaelnaufal.com/blog/2013/09/03/k-palindromes-puzzle/

Preparing for SharePoint TechCon, January 27th - 29th

Jul 21, 2013 · Eric Senunas

In Ruby:
v=[1,5,6,7,9,10];sum = v.reduce(:+);count=0;index = (0...v.size).detect { |i| count += v[i]; count * 2 == sum};index == nil ? nil : index + 1
Result: index = 4
Asynchronous JavaScript Testing with QUnit

Jun 20, 2013 · Tony Thomas

In Ruby:

(1..99999).select { |n| n % n.to_s.chars.map(&:to_i).reduce(:+) == 0 }
How to Combine REST Services with EJB 3.1

Dec 02, 2009 · Geertjan Wielenga

Good introduction to combine REST services with EJB! BTW, I think is the @EJB annotation which enables bean dependency injection by the container instead of the @Stateless annotation.
The Programmer from Hades

Dec 02, 2009 · Tad Anderson

Good introduction to combine REST services with EJB! BTW, I think is the @EJB annotation which enables bean dependency injection by the container instead of the @Stateless annotation.
JTable per-row Editors and Renderers

Feb 10, 2009 · Mr B Loid

@MarkThornton

"You supposed to throw an exception instead of using an assert. However this doesn't change the problem with respect to testing --- you have to provide a valid value."

What if the unnecessary values for testing would be substituted by "NullObjects"?

Then, the code would look like this:

testSecureHouse() {
Door door = new Door();
Window window = new Window();
House house = new House(door, window,
HouseTest.createRoofForTest(), HouseTest.createKitchenForTest(),
HouseTest.createLivingRoomForTest(),
HouseTest.createBedRoomForTest());

house.secure();

assertTrue(door.isLocked());
assertTrue(window.isClosed());
}

If Roof, Kitchen, LivingRoom and BedRoom were interfaces, the null objects can have the same contract (implementing the same interface). The null objects can have only one instance because there is no need to have a lot of instances of the same NullObject. Of course they don't need to be hard-coded, they can be configured and created with Test Data Builders. Each of the collaborators instantiate Null Objects that it depends.

JTable per-row Editors and Renderers

Feb 10, 2009 · Mr B Loid

Sometimes ago I blogged about ways of indicating the absence of an object:

http://rnaufal.livejournal.com/10017.html

One interesting comment I received about using Assert to validate input:

"There's a document in the JDK docs titled Programming With Assertions that says:

Do not use assertions for argument checking in public methods"

JTable per-row Editors and Renderers

Feb 10, 2009 · Mr B Loid

Sometimes ago I blogged about ways of indicating the absence of an object:

http://rnaufal.livejournal.com/10017.html

One interesting comment I received about using Assert to validate input:

"There's a document in the JDK docs titled Programming With Assertions that says:

Do not use assertions for argument checking in public methods"

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: